Removed or created shared header files used by print kit.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2091 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2002-11-26 23:03:14 +00:00
parent e14977562f
commit 2440d2c1cf
23 changed files with 1861 additions and 0 deletions
+101
View File
@@ -0,0 +1,101 @@
/*****************************************************************************/
// BeUtils.cpp
//
// Version: 1.0.0d1
//
// Several utilities for writing applications for the BeOS. It are small
// very specific functions, but generally useful (could be here because of a
// lack in the APIs, or just sheer lazyness :))
//
// Authors
// Ithamar R. Adema
// Michael Pfeiffer
//
// This application and all source files used in its construction, except
// where noted, are licensed under the MIT License, and have been written
// and are:
//
// Copyright (c) 2001, 2002 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef BEUTILS_H
#define BEUTILS_H
#include <FindDirectory.h>
#include <Path.h>
#include <SupportDefs.h>
#include <Picture.h>
#include <PictureButton.h>
#include <TranslatorFormats.h>
#include <TranslationUtils.h>
status_t TestForAddonExistence(const char* name, directory_which which,
const char* section, BPath& outPath);
// Reference counted object
class Object {
private:
volatile int32 fRefCount;
public:
// After construction reference count is 1
Object() : fRefCount(1) { }
// dtor should be private, but ie. ObjectList requires a public dtor!
virtual ~Object() { };
// thread-safe as long as thread that calls Acquire has already
// a reference to the object
void Acquire() {
atomic_add(&fRefCount, 1);
}
bool Release() {
if (atomic_add(&fRefCount, -1) == 1) {
delete this; return true;
} else {
return false;
}
}
};
// Automatically send a reply to sender on destruction of object
// and delete sender
class AutoReply {
BMessage* fSender;
BMessage fReply;
public:
AutoReply(BMessage* sender, uint32 what);
~AutoReply();
void SetReply(BMessage* m) { fReply = *m; }
};
// mimetype from sender
bool MimeTypeForSender(BMessage* sender, BString& mime);
// adds fields to message or replaces existing fields
bool AddFields(BMessage* to, const BMessage* from);
// load bitmap from application resources
BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP);
// convert bitmap to picture; view must be attached to a window!
// returns NULL if bitmap is NULL
BPicture *BitmapToPicture(BView* view, BBitmap *bitmap);
BPicture *BitmapToGrayedPicture(BView* view, BBitmap *bitmap);
#endif
+90
View File
@@ -0,0 +1,90 @@
/*****************************************************************************/
// FolderWatcher
//
// Author
// Michael Pfeiffer
//
// This application and all source files used in its construction, except
// where noted, are licensed under the MIT License, and have been written
// and are:
//
// Copyright (c) 2002 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef _FOLDER_WATCHER_H
#define _FOLDER_WATCHER_H
#include <Directory.h>
#include <Entry.h>
#include <Handler.h>
#include <Looper.h>
#include <String.h>
#include <StorageDefs.h>
class FolderListener {
public:
// entry created or moved into folder
virtual void EntryCreated(node_ref* node, entry_ref* entry) {};
// entry removed from folder (or moved to another folder)
virtual void EntryRemoved(node_ref* node) {};
// attribute of an entry has changed
virtual void AttributeChanged(node_ref* node) {};
};
// The class FolderWatcher watches creation, deletion of files in a directory
// and optionally watches attribute changes of files in the directory.
class FolderWatcher : public BHandler {
typedef BHandler inherited;
private:
BDirectory fFolder;
FolderListener* fListener;
bool fWatchAttrChanges;
bool BuildEntryRef(BMessage* msg, const char* dirName, entry_ref* entry);
bool BuildNodeRef(BMessage* msg, node_ref* node);
void HandleCreatedEntry(BMessage* msg, const char* dirName);
void HandleRemovedEntry(BMessage* msg);
void HandleChangedAttr(BMessage* msg);
public:
// start node watching (optionally watch attribute changes)
FolderWatcher(BLooper* looper, const BDirectory& folder, bool watchAttrChanges = false);
// stop node watching
virtual ~FolderWatcher();
void MessageReceived(BMessage* msg);
// the directory
BDirectory* Folder() { return &fFolder; }
// set listener that is notified of changes in the directory
void SetListener(FolderListener* listener);
// start/stop watching of attribute changes
status_t StartAttrWatching(node_ref* node);
status_t StopAttrWatching(node_ref* node);
};
#endif
+144
View File
@@ -0,0 +1,144 @@
/*****************************************************************************/
// Jobs
//
// Author
// Michael Pfeiffer
//
// This application and all source files used in its construction, except
// where noted, are licensed under the MIT License, and have been written
// and are:
//
// Copyright (c) 2002 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef _JOBS_H
#define _JOBS_H
#include "BeUtils.h"
#include "ObjectList.h"
#include "FolderWatcher.h"
#include <Directory.h>
#include <Entry.h>
#include <Handler.h>
#include <Locker.h>
#include <String.h>
#include <StorageDefs.h>
enum JobStatus { // job file
kWaiting, // to be processed
kProcessing, // processed by a printer add-on
kFailed, // failed to process the job file
kCompleted, // successfully processed
kUnknown, // other
};
class Printer;
class Folder;
// Job file in printer folder
class Job : public Object {
private:
Folder* fFolder; // the handler that watches the node of the job file
BString fName; // the name of the job file
long fTime; // the time encoded in the file name
node_ref fNode; // the node of the job file
entry_ref fEntry; // the entry of the job file
JobStatus fStatus; // the status of the job file
bool fValid; // is this a valid job file?
Printer* fPrinter; // the printer that processes this job
void UpdateStatus(const char* status);
void UpdateStatusAttribute(const char* status);
bool HasAttribute(BNode* node, const char* name);
bool IsValidJobFile();
public:
Job(const BEntry& entry, Folder* folder);
status_t InitCheck() const { return fTime >= 0 ? B_OK : B_ERROR; }
// accessors
const BString& Name() const { return fName; }
JobStatus Status() const { return fStatus; }
bool IsValid() const { return fValid; }
long Time() const { return fTime; }
const node_ref& NodeRef() const { return fNode; }
const entry_ref& EntryRef() const { return fEntry; }
bool IsWaiting() const { return fStatus == kWaiting; }
Printer* GetPrinter() const { return fPrinter; }
// modifiers
void SetPrinter(Printer* p) { fPrinter = p; }
void SetStatus(JobStatus s, bool writeToNode = true);
void UpdateAttribute();
void Remove();
};
// Printer folder watches creation, deletion and attribute changes of job files
// and notifies print_server if a job is waiting for processing
class Folder : public FolderWatcher, public FolderListener {
typedef FolderWatcher inherited;
private:
BLocker* fLocker;
BObjectList<Job> fJobs;
static int AscendingByTime(const Job* a, const Job* b);
bool AddJob(BEntry& entry, bool notify = true);
Job* Find(node_ref* node);
// FolderListener
void EntryCreated(node_ref* node, entry_ref* entry);
void EntryRemoved(node_ref* node);
void AttributeChanged(node_ref* node);
void SetupJobList();
protected:
enum {
kJobAdded,
kJobRemoved,
kJobAttrChanged,
};
virtual void Notify(Job* job, int kind) = 0;
public:
Folder(BLocker* fLocker, BLooper* looper, const BDirectory& spoolDir);
~Folder();
BDirectory* GetSpoolDir() { return inherited::Folder(); }
BLocker* Locker() const { return fLocker; }
bool Lock() const { return fLocker != NULL ? fLocker->Lock() : true; }
void Unlock() const { if (fLocker) fLocker->Unlock(); }
int32 CountJobs() const { return fJobs.CountItems(); }
Job* JobAt(int i) const { return fJobs.ItemAt(i); }
// Caller is responsible to set the status of the job appropriately
// and to release the object when done
Job* GetNextJob();
};
#endif
+93
View File
@@ -0,0 +1,93 @@
/*
PictureIterator.
Copyright (c) 2001, 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _PICTURE_ITERATOR_H
#define _PICTURE_TIERATOR_H
#include <AppKit.h>
#include <InterfaceKit.h>
class PictureIterator
{
public:
virtual ~PictureIterator() { }
// BPicture playback handlers
virtual void Op(int number) { }
virtual void MovePenBy(BPoint delta) { }
virtual void StrokeLine(BPoint start, BPoint end) { }
virtual void StrokeRect(BRect rect) { }
virtual void FillRect(BRect rect) { }
virtual void StrokeRoundRect(BRect rect, BPoint radii) { }
virtual void FillRoundRect(BRect rect, BPoint radii) { }
virtual void StrokeBezier(BPoint *control) { }
virtual void FillBezier(BPoint *control) { }
virtual void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta) { }
virtual void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta) { }
virtual void StrokeEllipse(BPoint center, BPoint radii) { }
virtual void FillEllipse(BPoint center, BPoint radii) { }
virtual void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed) { }
virtual void FillPolygon(int32 numPoints, BPoint *points, bool isClosed) { }
virtual void StrokeShape(BShape *shape) { }
virtual void FillShape(BShape *shape) { }
virtual void DrawString(char *string, float escapement_nospace, float escapement_space) { }
virtual void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data) { }
virtual void SetClippingRects(BRect *rects, uint32 numRects) { }
virtual void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture) { }
virtual void PushState() { }
virtual void PopState() { }
virtual void EnterStateChange() { }
virtual void ExitStateChange() { }
virtual void EnterFontState() { }
virtual void ExitFontState() { }
virtual void SetOrigin(BPoint pt) { }
virtual void SetPenLocation(BPoint pt) { }
virtual void SetDrawingMode(drawing_mode mode) { }
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit) { }
virtual void SetPenSize(float size) { }
virtual void SetForeColor(rgb_color color) { }
virtual void SetBackColor(rgb_color color) { }
virtual void SetStipplePattern(pattern p) { }
virtual void SetScale(float scale) { }
virtual void SetFontFamily(char *family) { }
virtual void SetFontStyle(char *style) { }
virtual void SetFontSpacing(int32 spacing) { }
virtual void SetFontSize(float size) { }
virtual void SetFontRotate(float rotation) { }
virtual void SetFontEncoding(int32 encoding) { }
virtual void SetFontFlags(int32 flags) { }
virtual void SetFontShear(float shear) { }
virtual void SetFontFace(int32 flags) { }
virtual void Iterate(BPicture* picture);
};
#endif _PICTURE_ITERATOR_H
+124
View File
@@ -0,0 +1,124 @@
/*
PicturePrinter
Copyright (c) 2001, 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _PICTURE_PRINTER_H
#define _PICTURE_PRINTER_H
#include "PictureIterator.h"
#include <Shape.h>
class PicturePrinter : public PictureIterator
{
public:
PicturePrinter(int indent = 0);
// BPicture playback handlers
virtual void Op(int number);
virtual void MovePenBy(BPoint delta);
virtual void StrokeLine(BPoint start, BPoint end);
virtual void StrokeRect(BRect rect);
virtual void FillRect(BRect rect);
virtual void StrokeRoundRect(BRect rect, BPoint radii);
virtual void FillRoundRect(BRect rect, BPoint radii);
virtual void StrokeBezier(BPoint *control);
virtual void FillBezier(BPoint *control);
virtual void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
virtual void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
virtual void StrokeEllipse(BPoint center, BPoint radii);
virtual void FillEllipse(BPoint center, BPoint radii);
virtual void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed);
virtual void FillPolygon(int32 numPoints, BPoint *points, bool isClosed);
virtual void StrokeShape(BShape *shape);
virtual void FillShape(BShape *shape);
virtual void DrawString(char *string, float escapement_nospace, float escapement_space);
virtual void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
virtual void SetClippingRects(BRect *rects, uint32 numRects);
virtual void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture);
virtual void PushState();
virtual void PopState();
virtual void EnterStateChange();
virtual void ExitStateChange();
virtual void EnterFontState();
virtual void ExitFontState();
virtual void SetOrigin(BPoint pt);
virtual void SetPenLocation(BPoint pt);
virtual void SetDrawingMode(drawing_mode mode);
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit);
virtual void SetPenSize(float size);
virtual void SetForeColor(rgb_color color);
virtual void SetBackColor(rgb_color color);
virtual void SetStipplePattern(pattern p);
virtual void SetScale(float scale);
virtual void SetFontFamily(char *family);
virtual void SetFontStyle(char *style);
virtual void SetFontSpacing(int32 spacing);
virtual void SetFontSize(float size);
virtual void SetFontRotate(float rotation);
virtual void SetFontEncoding(int32 encoding);
virtual void SetFontFlags(int32 flags);
virtual void SetFontShear(float shear);
virtual void SetFontFace(int32 flags);
private:
int fIndent;
void Print(const char* text);
void Print(BPoint* point);
void Print(BRect* rect);
void Print(int numPoints, BPoint* points);
void Print(int numRects, BRect* rects);
void Print(BShape* shape);
void Print(const char* label, float f);
void Print(const char* label, BPoint *point);
void Print(rgb_color color);
void Print(float f);
void Cr();
void Indent(int inc = 0);
void IncIndent();
void DecIndent();
friend class ShapePrinter;
};
class ShapePrinter : public BShapeIterator {
public:
ShapePrinter(PicturePrinter* printer);
~ShapePrinter();
status_t IterateBezierTo(int32 bezierCount, BPoint *bezierPoints);
status_t IterateClose(void);
status_t IterateLineTo(int32 lineCount, BPoint *linePoints);
status_t IterateMoveTo(BPoint *point);
private:
PicturePrinter* fPrinter;
};
#endif _PICTURE_PRINTER_H
+81
View File
@@ -0,0 +1,81 @@
/*
PrintJobReader
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <File.h>
#include <Message.h>
class PrintJobPage {
BFile fJobFile; // the job file
off_t fNextPicture; // offset to first picture
int32 fNumberOfPictures; // of this page
int32 fPicture; // the picture returned by NextPicture()
status_t fStatus;
public:
PrintJobPage();
PrintJobPage(const PrintJobPage& copy);
PrintJobPage(BFile* jobFile, off_t start);
status_t InitCheck() const;
int32 NumberOfPictures() const { return fNumberOfPictures; }
status_t NextPicture(BPicture& picture, BPoint& p, BRect& r);
PrintJobPage& operator=(const PrintJobPage& copy);
};
class PrintJobReader {
BFile fJobFile; // the job file
int32 fNumberOfPages; // the number of pages in the job file
int32 fFirstPage; // the page number of the first page
BMessage fJobSettings; // the settings extracted from the job file
off_t* fPageIndex; // start positions of pages in the job file
void BuildPageIndex();
public:
PrintJobReader(BFile* jobFile);
virtual ~PrintJobReader();
// test after construction if this is a valid job file
status_t InitCheck() const;
// accessors to informations from job file
int32 NumberOfPages() const { return fNumberOfPages; }
int32 FirstPage() const { return fFirstPage; }
int32 LastPage() const { return fFirstPage + fNumberOfPages - 1; }
const BMessage* JobSettings() const { return &fJobSettings; }
BRect PaperRect() const;
BRect PrintableRect() const;
void GetResolution(int32 *xdpi, int32 *ydpi) const;
// retrieve page
status_t GetPage(int no, PrintJobPage& pjp);
};
+85
View File
@@ -0,0 +1,85 @@
/*
Copyright (c) 2001, 2002 OpenBeOS.
Author:
<YOUR NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _TEMPLATE_H
#define _TEMPLATE_H
#include "PictureIterator.h"
class Template : public PictureIterator
{
public:
// BPicture playback handlers
virtual void Op(int number);
virtual void MovePenBy(BPoint delta);
virtual void StrokeLine(BPoint start, BPoint end);
virtual void StrokeRect(BRect rect);
virtual void FillRect(BRect rect);
virtual void StrokeRoundRect(BRect rect, BPoint radii);
virtual void FillRoundRect(BRect rect, BPoint radii);
virtual void StrokeBezier(BPoint *control);
virtual void FillBezier(BPoint *control);
virtual void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
virtual void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
virtual void StrokeEllipse(BPoint center, BPoint radii);
virtual void FillEllipse(BPoint center, BPoint radii);
virtual void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed);
virtual void FillPolygon(int32 numPoints, BPoint *points, bool isClosed);
virtual void StrokeShape(BShape *shape);
virtual void FillShape(BShape *shape);
virtual void DrawString(char *string, float escapement_nospace, float escapement_space);
virtual void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
virtual void SetClippingRects(BRect *rects, uint32 numRects);
virtual void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture);
virtual void PushState();
virtual void PopState();
virtual void EnterStateChange();
virtual void ExitStateChange();
virtual void EnterFontState();
virtual void ExitFontState();
virtual void SetOrigin(BPoint pt);
virtual void SetPenLocation(BPoint pt);
virtual void SetDrawingMode(drawing_mode mode);
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit);
virtual void SetPenSize(float size);
virtual void SetForeColor(rgb_color color);
virtual void SetBackColor(rgb_color color);
virtual void SetStipplePattern(pattern p);
virtual void SetScale(float scale);
virtual void SetFontFamily(char *family);
virtual void SetFontStyle(char *style);
virtual void SetFontSpacing(int32 spacing);
virtual void SetFontSize(float size);
virtual void SetFontRotate(float rotation);
virtual void SetFontEncoding(int32 encoding);
virtual void SetFontFlags(int32 flags);
virtual void SetFontShear(float shear);
virtual void SetFontFace(int32 flags);
};
#endif _TEMPLATE_H
+16
View File
@@ -0,0 +1,16 @@
/*
* AboutBox.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __ABOUTBOX_H
#define __ABOUTBOX_H
#include <Application.h>
class AboutBox : public BApplication {
public:
AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright);
};
#endif /* __ABOUTBOX_H */
+26
View File
@@ -0,0 +1,26 @@
/*
* DbgMsg.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __DBGMSG_H
#define __DBGMSG_H
//#define DBG
#ifdef DBG
void write_debug_stream(const char *, ...);
void DUMP_BFILE(BFile *file, const char *name);
void DUMP_BMESSAGE(BMessage *msg);
void DUMP_BDIRECTORY(BDirectory *dir);
void DUMP_BNODE(BNode *node);
#define DBGMSG(args) write_debug_stream args
#else
#define DUMP_BFILE(file, name) (void)0
#define DUMP_BMESSAGE(msg) (void)0
#define DUMP_BDIRECTORY(dir) (void)0
#define DUMP_BNODE(node) (void)0
#define DBGMSG(args) (void)0
#endif
#endif /* __DBGMSG_H */
+22
View File
@@ -0,0 +1,22 @@
/*
* Exports.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __EXPORTS_H
#define __EXPORTS_H
#include <BeBuild.h>
class BNode;
class BMessage;
class BFile;
extern "C" {
_EXPORT char *add_printer(char *printer_name);
_EXPORT BMessage *config_page(BNode *node, BMessage *msg);
_EXPORT BMessage *config_job(BNode *node, BMessage *msg);
_EXPORT BMessage *take_job(BFile *spool_file, BNode *node, BMessage *msg);
}
#endif // __EXPORTS_H
@@ -0,0 +1,114 @@
/*
* GraphicsDriver.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __GRAPHICSDRIVER_H
#define __GRAPHICSDRIVER_H
#include "JobData.h"
#include "PrintProcess.h"
#include "Transport.h"
class BView;
class BBitmap;
class BMessage;
class PrinterData;
class PrinterCap;
#define GDF_ROTATE_BAND_BITMAP 0x01
class GraphicsDriver {
public:
GraphicsDriver(BMessage *, PrinterData *, const PrinterCap *);
virtual ~GraphicsDriver();
BMessage *takeJob(BFile *spool, uint32 flags = 0);
protected:
virtual bool startDoc();
virtual bool startPage(int page_number);
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
virtual bool endPage(int page_number);
virtual bool endDoc(bool success);
void writeSpoolData(const void *buffer, size_t size) throw(TransportException);
void writeSpoolString(const char *buffer, ...) throw(TransportException);
void writeSpoolChar(char c) throw(TransportException);
const JobData *getJobData() const;
const PrinterData *getPrinterData() const;
const PrinterCap *getPrinterCap() const;
int getPageWidth() const;
int getPageHeight() const;
int getBandWidth() const;
int getBandHeight() const;
int getPixelDepth() const;
GraphicsDriver(const GraphicsDriver &);
GraphicsDriver &operator = (const GraphicsDriver &);
private:
void setupData(BFile *file, long page_count);
void setupBitmap();
void cleanupData();
void cleanupBitmap();
bool printPage(PageDataList *pages);
bool printDocument(SpoolData *spool_data);
bool printJob(BFile *file);
uint32 __flags;
BMessage *__msg;
BView *__view;
BBitmap *__bitmap;
Transport *__transport;
JobData *__org_job_data;
JobData *__real_job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
int __page_width;
int __page_height;
int __band_width;
int __band_height;
int __pixel_depth;
int __band_count;
int __internal_copies;
};
inline const JobData *GraphicsDriver::getJobData() const
{
return __real_job_data;
}
inline const PrinterData *GraphicsDriver::getPrinterData() const
{
return __printer_data;
}
inline const PrinterCap *GraphicsDriver::getPrinterCap() const
{
return __printer_cap;
}
inline int GraphicsDriver::getPageWidth() const
{
return __page_width;
}
inline int GraphicsDriver::getPageHeight() const
{
return __page_height;
}
inline int GraphicsDriver::getBandWidth() const
{
return __band_width;
}
inline int GraphicsDriver::getBandHeight() const
{
return __band_height;
}
#endif /* __GRAPHICSDRIVER_H */
+87
View File
@@ -0,0 +1,87 @@
/*
* HalftoneEngine.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __HALFTONE_H
#define __HALFTONE_H
#include <GraphicsDefs.h>
struct CACHE_FOR_CMAP8 {
uint density;
bool hit;
};
class Halftone;
typedef int (Halftone::*PFN_dither)(uchar *dst, const uchar *src, int x, int y, int width);
typedef uint (*PFN_gray)(rgb_color c);
class Halftone {
public:
enum DITHERTYPE {
TYPE1,
TYPE2,
TYPE3
};
Halftone(color_space cs, double gamma = 1.4, DITHERTYPE dither_type = TYPE3);
~Halftone();
int dither(uchar *dst, const uchar *src, int x, int y, int width);
int getPixelDepth() const;
const rgb_color *getPalette() const;
const uchar *getPattern() const;
void setPattern(const uchar *pattern);
PFN_gray getGrayFunction() const;
void setGrayFunction(PFN_gray gray);
protected:
void createGammaTable(double gamma);
void initElements(int x, int y, uchar *elements);
int ditherGRAY1(uchar *dst, const uchar *src, int x, int y, int width);
int ditherGRAY8(uchar *dst, const uchar *src, int x, int y, int width);
int ditherCMAP8(uchar *dst, const uchar *src, int x, int y, int width);
int ditherRGB32(uchar *dst, const uchar *src, int x, int y, int width);
Halftone(const Halftone &);
Halftone &operator = (const Halftone &);
private:
PFN_dither __dither;
PFN_gray __gray;
int __pixel_depth;
const rgb_color *__palette;
const uchar *__pattern;
uint __gamma_table[256];
CACHE_FOR_CMAP8 __cache_table[256];
};
inline int Halftone::getPixelDepth() const
{
return __pixel_depth;
}
inline const rgb_color *Halftone::getPalette() const
{
return __palette;
}
inline const uchar * Halftone::getPattern() const
{
return __pattern;
}
inline void Halftone::setPattern(const uchar *pattern)
{
__pattern = pattern;
}
inline PFN_gray Halftone::getGrayFunction() const
{
return __gray;
}
inline void Halftone::setGrayFunction(PFN_gray gray)
{
__gray = gray;
}
#endif /* __HALFTONE_H */
+305
View File
@@ -0,0 +1,305 @@
/*
* JobData.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __JOBDATA_H
#define __JOBDATA_H
#include <SupportDefs.h>
#include <GraphicsDefs.h>
#include <Rect.h>
class BMessage;
class PrinterCap;
class JobData {
public:
enum ORIENTATION {
PORTRAIT,
LANDSCAPE
};
enum PAPER {
LETTER = 1, // 1 Letter 8 1/2 x 11 in
LETTERSMALL, // 2 Letter Small 8 1/2 x 11 in
TABLOID, // 3 Tabloid 11 x 17 in
LEDGER, // 4 Ledger 17 x 11 in
LEGAL, // 5 Legal 8 1/2 x 14 in
STATEMENT, // 6 Statement 5 1/2 x 8 1/2 in
EXECUTIVE, // 7 Executive 7 1/4 x 10 1/2 in
A3, // 8 A3 297 x 420 mm
A4, // 9 A4 210 x 297 mm
A4SMALL, // 10 A4 Small 210 x 297 mm
A5, // 11 A5 148 x 210 mm
B4, // 12 B4 (JIS) 250 x 354
B5, // 13 B5 (JIS) 182 x 257 mm
FOLIO, // 14 Folio 8 1/2 x 13 in
QUARTO, // 15 Quarto 215 x 275 mm
P_10X14, // 16 10x14 in
P_11X17, // 17 11x17 in
NOTE, // 18 Note 8 1/2 x 11 in
ENV_9, // 19 Envelope #9 3 7/8 x 8 7/8
ENV_10, // 20 Envelope #10 4 1/8 x 9 1/2
ENV_11, // 21 Envelope #11 4 1/2 x 10 3/8
ENV_12, // 22 Envelope #12 4 \276 x 11
ENV_14, // 23 Envelope #14 5 x 11 1/2
CSHEET, // 24 C size sheet
DSHEET, // 25 D size sheet
ESHEET, // 26 E size sheet
ENV_DL, // 27 Envelope DL 110 x 220mm
ENV_C5, // 28 Envelope C5 162 x 229 mm
ENV_C3, // 29 Envelope C3 324 x 458 mm
ENV_C4, // 30 Envelope C4 229 x 324 mm
ENV_C6, // 31 Envelope C6 114 x 162 mm
ENV_C65, // 32 Envelope C65 114 x 229 mm
ENV_B4, // 33 Envelope B4 250 x 353 mm
ENV_B5, // 34 Envelope B5 176 x 250 mm
ENV_B6, // 35 Envelope B6 176 x 125 mm
ENV_ITALY, // 36 Envelope 110 x 230 mm
ENV_MONARCH, // 37 Envelope Monarch 3.875 x 7.5 in
ENV_PERSONAL, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in
FANFOLD_US, // 39 US Std Fanfold 14 7/8 x 11 in
FANFOLD_STD_GERMAN, // 40 German Std Fanfold 8 1/2 x 12 in
FANFOLD_LGL_GERMAN, // 41 German Legal Fanfold 8 1/2 x 13 in
ISO_B4, // 42 B4 (ISO) 250 x 353 mm
JAPANESE_POSTCARD, // 43 Japanese Postcard 100 x 148 mm
P_9X11, // 44 9 x 11 in
P_10X11, // 45 10 x 11 in
P_15X11, // 46 15 x 11 in
ENV_INVITE, // 47 Envelope Invite 220 x 220 mm
RESERVED_48, // 48 RESERVED--DO NOT USE
RESERVED_49, // 49 RESERVED--DO NOT USE
LETTER_EXTRA, // 50 Letter Extra 9 \275 x 12 in
LEGAL_EXTRA, // 51 Legal Extra 9 \275 x 15 in
TABLOID_EXTRA, // 52 Tabloid Extra 11.69 x 18 in
A4_EXTRA, // 53 A4 Extra 9.27 x 12.69 in
LETTER_TRANSVERSE, // 54 Letter Transverse 8 \275 x 11 in
A4_TRANSVERSE, // 55 A4 Transverse 210 x 297 mm
LETTER_EXTRA_TRANSVERSE,// 56 Letter Extra Transverse 9\275 x 12 in
A_PLUS, // 57 SuperA/SuperA/A4 227 x 356 mm
B_PLUS, // 58 SuperB/SuperB/A3 305 x 487 mm
LETTER_PLUS, // 59 Letter Plus 8.5 x 12.69 in
A4_PLUS, // 60 A4 Plus 210 x 330 mm
A5_TRANSVERSE, // 61 A5 Transverse 148 x 210 mm
B5_TRANSVERSE, // 62 B5 (JIS) Transverse 182 x 257 mm
A3_EXTRA, // 63 A3 Extra 322 x 445 mm
A5_EXTRA, // 64 A5 Extra 174 x 235 mm
B5_EXTRA, // 65 B5 (ISO) Extra 201 x 276 mm
A2, // 66 A2 420 x 594 mm
A3_TRANSVERSE, // 67 A3 Transverse 297 x 420 mm
A3_EXTRA_TRANSVERSE, // 68 A3 Extra Transverse 322 x 445 mm
DBL_JAPANESE_POSTCARD, // 69 Japanese Double Postcard 200 x 148 mm
A6, // 70 A6 105 x 148 mm
JENV_KAKU2, // 71 Japanese Envelope Kaku #2
JENV_KAKU3, // 72 Japanese Envelope Kaku #3
JENV_CHOU3, // 73 Japanese Envelope Chou #3
JENV_CHOU4, // 74 Japanese Envelope Chou #4
LETTER_ROTATED, // 75 Letter Rotated 11 x 8 1/2 11 in
A3_ROTATED, // 76 A3 Rotated 420 x 297 mm
A4_ROTATED, // 77 A4 Rotated 297 x 210 mm
A5_ROTATED, // 78 A5 Rotated 210 x 148 mm
B4_JIS_ROTATED, // 79 B4 (JIS) Rotated 364 x 257 mm
B5_JIS_ROTATED, // 80 B5 (JIS) Rotated 257 x 182 mm
JAPANESE_POSTCARD_ROTATED, // 81 Japanese Postcard Rotated 148 x 100 mm
DBL_JAPANESE_POSTCARD_ROTATED, // 82 Double Japanese Postcard Rotated 148 x 200 mm
A6_ROTATED, // 83 A6 Rotated 148 x 105 mm
JENV_KAKU2_ROTATED, // 84 Japanese Envelope Kaku #2 Rotated
JENV_KAKU3_ROTATED, // 85 Japanese Envelope Kaku #3 Rotated
JENV_CHOU3_ROTATED, // 86 Japanese Envelope Chou #3 Rotated
JENV_CHOU4_ROTATED, // 87 Japanese Envelope Chou #4 Rotated
B6_JIS, // 88 B6 (JIS) 128 x 182 mm
B6_JIS_ROTATED, // 89 B6 (JIS) Rotated 182 x 128 mm
P_12X11, // 90 12 x 11 in
JENV_YOU4, // 91 Japanese Envelope You #4
JENV_YOU4_ROTATED, // 92 Japanese Envelope You #4 Rotated
P16K, // 93 PRC 16K 146 x 215 mm
P32K, // 94 PRC 32K 97 x 151 mm
P32KBIG, // 95 PRC 32K(Big) 97 x 151 mm
PENV_1, // 96 PRC Envelope #1 102 x 165 mm
PENV_2, // 97 PRC Envelope #2 102 x 176 mm
PENV_3, // 98 PRC Envelope #3 125 x 176 mm
PENV_4, // 99 PRC Envelope #4 110 x 208 mm
PENV_5, // 100 PRC Envelope #5 110 x 220 mm
PENV_6, // 101 PRC Envelope #6 120 x 230 mm
PENV_7, // 102 PRC Envelope #7 160 x 230 mm
PENV_8, // 103 PRC Envelope #8 120 x 309 mm
PENV_9, // 104 PRC Envelope #9 229 x 324 mm
PENV_10, // 105 PRC Envelope #10 324 x 458 mm
P16K_ROTATED, // 106 PRC 16K Rotated
P32K_ROTATED, // 107 PRC 32K Rotated
P32KBIG_ROTATED, // 108 PRC 32K(Big) Rotated
PENV_1_ROTATED, // 109 PRC Envelope #1 Rotated 165 x 102 mm
PENV_2_ROTATED, // 110 PRC Envelope #2 Rotated 176 x 102 mm
PENV_3_ROTATED, // 111 PRC Envelope #3 Rotated 176 x 125 mm
PENV_4_ROTATED, // 112 PRC Envelope #4 Rotated 208 x 110 mm
PENV_5_ROTATED, // 113 PRC Envelope #5 Rotated 220 x 110 mm
PENV_6_ROTATED, // 114 PRC Envelope #6 Rotated 230 x 120 mm
PENV_7_ROTATED, // 115 PRC Envelope #7 Rotated 230 x 160 mm
PENV_8_ROTATED, // 116 PRC Envelope #8 Rotated 309 x 120 mm
PENV_9_ROTATED, // 117 PRC Envelope #9 Rotated 324 x 229 mm
PENV_10_ROTATED, // 118 PRC Envelope #10 Rotated 458 x 324 mm
USER_DEFINED = 256
};
enum PAPERSOURCE {
AUTO, // 7 o
MANUAL, // 4 o
UPPER, // 1 o
MIDDLE, // 3 o
LOWER, // 2 o
// ONLYONE, // 1 x
// ENVELOPE, // 5 o
// ENVMANUAL, // 6 x
// TRACTOR, // 8 x
// SMALLFMT, // 9 x
// LARGEFMT, // 10 x
// LARGECAPACITY, // 11 x
// CASSETTE, // 14 x
// FORMSOURCE, // 15 x
CASSETTE1 = 21,
CASSETTE2,
CASSETTE3,
CASSETTE4,
CASSETTE5,
CASSETTE6,
CASSETTE7,
CASSETTE8,
CASSETTE9,
USER = 256 // device specific bins start here
};
enum PRINTSTYLE {
SIMPLEX,
DUPLEX,
BOOKLET
};
enum BINDINGLOCATION {
LONG_EDGE_LEFT,
LONG_EDGE_RIGHT,
SHORT_EDGE_TOP,
SHORT_EDGE_BOTTOM,
LONG_EDGE = LONG_EDGE_LEFT,
SHORT_EDGE = SHORT_EDGE_TOP
};
enum PAGEORDER {
ACROSS_FROM_LEFT,
DOWN_FROM_LEFT,
ACROSS_FROM_RIGHT,
DOWN_FROM_RIGHT,
LEFT_TO_RIGHT = ACROSS_FROM_LEFT,
RIGHT_TO_LEFT = ACROSS_FROM_RIGHT
};
/*
enum QUALITY {
DRAFT = -1,
LOW = -2,
MEDIUM = -3,
HIGH = -4
};
enum COLOR {
MONOCHROME = 1,
COLOR
};
*/
private:
PAPER __paper;
int32 __xres;
int32 __yres;
ORIENTATION __orientation;
float __scaling;
BRect __paper_rect;
BRect __printable_rect;
int32 __nup;
int32 __first_page;
int32 __last_page;
color_space __surface_type;
float __gamma;
PAPERSOURCE __paper_source;
int32 __copies;
bool __collate;
bool __reverse;
PRINTSTYLE __print_style;
BINDINGLOCATION __binding_location;
PAGEORDER __page_order;
BMessage *__msg;
public:
JobData(BMessage *msg, const PrinterCap *cap);
~JobData();
JobData(const JobData &job_data);
JobData &operator = (const JobData &job_data);
void load(BMessage *msg, const PrinterCap *cap);
void save(BMessage *msg = NULL);
PAPER getPaper() const { return __paper; }
void setPaper(PAPER paper) { __paper = paper; }
int32 getXres() const { return __xres; }
void setXres(int32 xres) { __xres = xres; }
int32 getYres() const { return __yres; }
void setYres(int32 yres) { __yres = yres; };
ORIENTATION getOrientation() const { return __orientation; }
void setOrientation(ORIENTATION orientation) { __orientation = orientation; }
float getScaling() const { return __scaling; }
void setScaling(float scaling) { __scaling = scaling; }
const BRect &getPaperRect() const { return __paper_rect; }
void setPaperRect(const BRect &paper_rect) { __paper_rect = paper_rect; }
const BRect &getPrintableRect() const { return __printable_rect; }
void setPrintableRect(const BRect &printable_rect) { __printable_rect = printable_rect; }
int32 getNup() const { return __nup; }
void setNup(int32 nup) { __nup = nup; }
bool getReverse() const { return __reverse; }
void setReverse(bool reverse) { __reverse = reverse; }
int32 getFirstPage() const { return __first_page; }
void setFirstPage(int32 first_page) { __first_page = first_page; }
int32 getLastPage() const { return __last_page; }
void setLastPage(int32 last_page) { __last_page = last_page; }
color_space getSurfaceType() const { return __surface_type; }
void setSurfaceType(color_space surface_type) { __surface_type = surface_type; }
float getGamma() const { return __gamma; }
void setGamma(float gamma) { __gamma = gamma; }
PAPERSOURCE getPaperSource() const { return __paper_source; }
void setPaperSource(PAPERSOURCE paper_source) { __paper_source = paper_source; };
int32 getCopies() const { return __copies; }
void setCopies(int32 copies) { __copies = copies; }
bool getCollate() const { return __collate; }
void setCollate(bool collate) { __collate = collate; }
PRINTSTYLE getPrintStyle() const { return __print_style; }
void setPrintStyle(PRINTSTYLE print_style) { __print_style = print_style; }
BINDINGLOCATION getBindingLocation() const { return __binding_location; }
void setBindingLocation(BINDINGLOCATION binding_location) { __binding_location = binding_location; }
PAGEORDER getPageOrder() const { return __page_order; }
void setPageOrder(PAGEORDER page_order) { __page_order = page_order; }
/*
protected:
JobData(const JobData &job_data);
JobData &operator = (const JobData &job_data);
*/
};
#endif /* __JOBDATA_H */
@@ -0,0 +1,60 @@
/*
* JobSetupDlg.cpp
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __JOBSETUPDLG_H
#define __JOBSETUPDLG_H
#include <View.h>
#include <Window.h>
class BTextControl;
class BRadioButton;
class BCheckBox;
class BPopUpMenu;
class JobData;
class PrinterData;
class PrinterCap;
class JobSetupView : public BView {
public:
JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *msg);
bool UpdateJobData();
public:
BTextControl *copies;
BTextControl *from_page;
BTextControl *to_page;
private:
JobData *__job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
BTextControl *__gamma;
BRadioButton *__all;
BCheckBox *__collate;
BCheckBox *__reverse;
BPopUpMenu *__surface_type;
BPopUpMenu *__paper_feed;
BCheckBox *__duplex;
BPopUpMenu *__nup;
};
class JobSetupDlg : public BWindow {
public:
JobSetupDlg(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
~JobSetupDlg();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
int Go();
private:
int __result;
long __semaphore;
BMessageFilter *__filter;
};
#endif /* __JOBSETUPDLG_H */
@@ -0,0 +1,48 @@
/*
* PageSetupDlg.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __PAGESETUPDLG_H
#define __PAGESETUPDLG_H
#include <View.h>
#include <Window.h>
class BRadioButton;
class BPopUpMenu;
class JobData;
class PrinterData;
class PrinterCap;
class PageSetupView : public BView {
public:
PageSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
~PageSetupView();
virtual void AttachedToWindow();
bool UpdateJobData();
private:
JobData *__job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
BRadioButton *__portrait;
BPopUpMenu *__paper;
BPopUpMenu *__resolution;
};
class PageSetupDlg : public BWindow {
public:
PageSetupDlg(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
~PageSetupDlg();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
int Go();
private:
int __result;
long __semaphore;
BMessageFilter *__filter;
};
#endif /* __PAGESETUPDLG_H */
+57
View File
@@ -0,0 +1,57 @@
const unsigned char pattern16x16_type1[] = {
0,128, 32,160, 8,136, 40,168, 2,130, 34,162, 10,138, 42,170,
192, 64,224, 96,200, 72,232,104,194, 66,226, 98,202, 74,234,106,
48,176, 16,144, 56,184, 24,152, 50,178, 18,146, 58,186, 26,154,
240,112,208, 80,248,120,216, 88,242,114,210, 82,250,122,218, 90,
12,140, 44,172, 4,132, 36,164, 14,142, 46,174, 6,134, 38,166,
204, 76,236,108,196, 68,228,100,206, 78,238,110,198, 70,230,102,
60,188, 28,156, 52,180, 20,148, 62,190, 30,158, 54,182, 22,150,
252,124,220, 92,244,116,212, 84,254,126,222, 94,246,118,214, 86,
3,131, 35,163, 11,139, 43,171, 1,129, 33,161, 9,137, 41,169,
195, 67,227, 99,203, 75,235,107,193, 65,225, 97,201, 73,233,105,
51,179, 19,147, 59,187, 27,155, 49,177, 17,145, 57,185, 25,153,
243,115,211, 83,251,123,219, 91,241,113,209, 81,249,121,217, 89,
15,143, 47,175, 7,135, 39,167, 13,141, 45,173, 5,133, 37,165,
207, 79,239,111,199, 71,231,103,205, 77,237,109,197, 69,229,101,
63,191, 31,159, 55,183, 23,151, 61,189, 29,157, 53,181, 21,149,
255,127,223, 95,247,119,215, 87,253,125,221, 93,245,117,213, 85
};
const unsigned char pattern16x16_type2[] = {
153,137,121,105,152,136,120,104,151,135,119,103,150,134,118,102,
169, 25, 9, 89,168, 24, 8, 88,167, 23, 7, 87,166, 22, 6, 86,
185, 41, 57, 73,184, 40, 56, 72,183, 39, 55, 71,182, 38, 54, 70,
201,217,233,249,200,216,232,248,199,215,231,247,198,214,230,246,
154,138,122,106,145,129,113, 97,144,128,112, 96,149,133,117,101,
170, 26, 10, 90,161, 17, 1, 81,160, 16, 0, 80,165, 21, 5, 85,
186, 42, 58, 74,177, 33, 49, 65,176, 32, 48, 64,181, 37, 53, 69,
202,218,234,250,193,209,225,241,192,208,224,240,197,213,229,245,
155,139,123,107,146,130,114, 98,147,131,115, 99,148,132,116,100,
171, 27, 11, 91,162, 18, 2, 82,163, 19, 3, 83,164, 20, 4, 84,
187, 43, 59, 75,178, 34, 50, 66,179, 35, 51, 67,180, 36, 52, 68,
203,219,235,251,194,210,226,242,195,211,227,243,196,212,228,244,
156,140,124,108,157,141,125,109,158,142,126,110,159,143,127,111,
172, 28, 12, 92,173, 29, 13, 93,174, 30, 14, 94,175, 31, 15, 95,
188, 44, 60, 76,189, 45, 61, 77,190, 46, 62, 78,191, 47, 63, 79,
204,220,236,252,205,221,237,253,206,222,238,254,207,223,239,255
};
const unsigned char pattern16x16_type3[] = {
0, 32,224,192, 2, 34,226,194, 14, 46,238,206, 12, 44,236,204,
128,160, 80,112,130,162, 82,114,142,174, 94,126,140,172, 92,124,
240,208, 16, 48,242,210, 18, 50,254,222, 30, 62,252,220, 28, 60,
64, 96,144,176, 66, 98,146,178, 78,110,158,190, 76,108,156,188,
8, 40,232,200, 10, 42,234,202, 5, 37,229,197, 7, 39,231,199,
136,168, 88,120,138,170, 90,122,133,165, 85,117,135,167, 87,119,
248,216, 24, 56,250,218, 26, 58,245,213, 21, 53,247,215, 23, 55,
72,104,152,184, 74,106,154,186, 69,101,149,181, 71,103,151,183,
15, 47,239,207, 13, 45,237,205, 1, 33,225,193, 3, 35,227,195,
143,175, 95,127,141,173, 93,125,129,161, 81,113,131,163, 83,115,
255,223, 31, 63,253,221, 29, 61,241,209, 17, 49,243,211, 19, 51,
79,111,159,191, 77,109,157,189, 65, 97,145,177, 67, 99,147,179,
4, 36,228,196, 6, 38,230,198, 9, 41,233,201, 11, 43,235,203,
132,164, 84,116,134,166, 86,118,137,169, 89,121,139,171, 91,123,
244,212, 20, 52,246,214, 22, 54,249,217, 25, 57,251,219, 27, 59,
68,100,148,180, 70,102,150,182, 73,105,153,185, 75,107,155,187
};
+29
View File
@@ -0,0 +1,29 @@
/*
* Preview.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
//#define USE_PREVIEW_FOR_DEBUG
#ifdef USE_PREVIEW_FOR_DEBUG
#ifndef __PREVIEW_H
#define __PREVIEW_H
#include <Window.h>
class PreviewWindow : public BWindow {
public:
PreviewWindow(BRect, const char *, BBitmap *);
virtual bool QuitRequested();
int Go();
protected:
PreviewWindow(const PreviewWindow &);
PreviewWindow &operator = (const PreviewWindow &);
private:
long __semaphore;
};
#endif /* __PREVIEW_H */
#endif /* USE_PREVIEW_FOR_DEBUG */
@@ -0,0 +1,64 @@
/*
* PrintProcess.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __PRINTPROCESS_H
#define __PRINTPROCESS_H
#include <vector>
#include <list>
#include <memory>
#include <Rect.h>
#include <Point.h>
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
class BFile;
class BPicture;
class PictureData {
public:
PictureData(BFile *file);
~PictureData();
BPoint point;
BRect rect;
BPicture *picture;
};
class PageData {
public:
PageData();
PageData(BFile *file, bool reverse);
bool startEnum();
bool enumObject(PictureData **);
private:
BFile *__file;
bool __reverse;
int __picture_count;
int __rest;
off_t __offset;
bool __hollow;
};
typedef list<PageData *> PageDataList;
class SpoolData {
public:
SpoolData(BFile *file, int page_count, int nup, bool reverse);
~SpoolData();
bool startEnum();
bool enumObject(PageData **);
private:
PageDataList __pages;
PageDataList::iterator __it;
};
#endif /* __PRINTPROCESS_H */
+117
View File
@@ -0,0 +1,117 @@
/*
* PrinterCap.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __PRINTERCAP_H
#define __PRINTERCAP_H
#include <string>
#include <Rect.h>
#include "JobData.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
#define UNKNOWN_PRINTER 0
struct BaseCap {
string label;
bool is_default;
BaseCap(const string &n, bool d) : label(n), is_default(d) {}
};
struct PaperCap : public BaseCap {
JobData::PAPER paper;
BRect paper_rect;
BRect printable_rect;
PaperCap(const string &n, bool d, JobData::PAPER p, const BRect &r1, const BRect &r2)
: BaseCap(n, d), paper(p), paper_rect(r1), printable_rect(r2) {}
};
struct PaperSourceCap : public BaseCap {
JobData::PAPERSOURCE paper_source;
PaperSourceCap(const string &n, bool d, JobData::PAPERSOURCE f)
: BaseCap(n, d), paper_source(f) {}
};
struct ResolutionCap : public BaseCap {
int xres;
int yres;
ResolutionCap(const string &n, bool d, int x, int y)
: BaseCap(n, d), xres(x), yres(y) {}
};
struct OrientationCap : public BaseCap {
JobData::ORIENTATION orientation;
OrientationCap(const string &n, bool d, JobData::ORIENTATION o)
: BaseCap(n, d), orientation(o) {}
};
struct PrintStyleCap : public BaseCap {
JobData::PRINTSTYLE print_style;
PrintStyleCap(const string &n, bool d, JobData::PRINTSTYLE x)
: BaseCap(n, d), print_style(x) {}
};
struct BindingLocationCap : public BaseCap {
JobData::BINDINGLOCATION binding_location;
BindingLocationCap(const string &n, bool d, JobData::BINDINGLOCATION b)
: BaseCap(n, d), binding_location(b) {}
};
class PrinterData;
class PrinterCap {
public:
PrinterCap(const PrinterData *printer_data);
virtual ~PrinterCap();
/*
PrinterCap(const PrinterCap &printer_cap);
PrinterCap &operator = (const PrinterCap &printer_cap);
*/
enum CAPID {
PAPER,
PAPERSOURCE,
RESOLUTION,
ORIENTATION,
PRINTSTYLE,
BINDINGLOCATION
};
virtual int countCap(CAPID) const = 0;
virtual bool isSupport(CAPID) const = 0;
virtual const BaseCap **enumCap(CAPID) const = 0;
const BaseCap *getDefaultCap(CAPID) const;
int getPrinterId() const;
protected:
PrinterCap(const PrinterCap &);
PrinterCap &operator = (const PrinterCap &);
const PrinterData *getPrinterData() const;
void setPrinterId(int id);
private:
const PrinterData *__printer_data;
int __printer_id;
};
inline const PrinterData *PrinterCap::getPrinterData() const
{
return __printer_data;
}
inline int PrinterCap::getPrinterId() const
{
return __printer_id;
}
inline void PrinterCap::setPrinterId(int id)
{
__printer_id = id;
}
#endif /* __PRINTERCAP_H */
@@ -0,0 +1,84 @@
/*
* PrinterData.h
* Copyright 1999-2000 Y.Takagi All Rights Reserved.
*/
#ifndef __PRINTERDATA_H
#define __PRINTERDATA_H
#include <string>
#include <SerialPort.h>
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
class BNode;
class PrinterData {
public:
PrinterData(BNode *node = NULL);
~PrinterData();
/*
PrinterData(const PrinterData &printer_data);
PrinterData &operator = (const PrinterData &printer_data);
*/
void load(BNode *node);
// void save(BNode *node = NULL);
const string &getDriverName() const;
const string &getPrinterName() const;
const string &getComments() const;
const string &getTransport() const;
// void setDriverName(const char *s) { __driver_name = driver_name; }
void setPrinterName(const char *printer_name);
void setComments(const char *comments);
bool getPath(char *path) const;
protected:
PrinterData(const PrinterData &printer_data);
PrinterData &operator = (const PrinterData &printer_data);
private:
string __driver_name;
string __printer_name;
string __comments;
string __transport;
BNode *__node;
};
inline const string &PrinterData::getDriverName() const
{
return __driver_name;
}
inline const string &PrinterData::getPrinterName() const
{
return __printer_name;
}
inline const string &PrinterData::getComments() const
{
return __comments;
}
inline const string &PrinterData::getTransport() const
{
return __transport;
}
inline void PrinterData::setPrinterName(const char *printer_name)
{
__printer_name = printer_name;
}
inline void PrinterData::setComments(const char *comments)
{
__comments = comments;
}
#endif // __PRINTERDATA_H
@@ -0,0 +1,56 @@
/*
* Transport.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __TRANSPORT_H
#define __TRANSPORT_H
#include <image.h>
#include <string>
class BDataIO;
class PrinterData;
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
extern "C" {
typedef BDataIO *(*PFN_init_transport)(BMessage *);
typedef void (*PFN_exit_transport)(void);
}
class TransportException {
private:
string __str;
public:
TransportException(const string &what_arg) : __str(what_arg) {}
const char *what() const { return __str.c_str(); }
};
class Transport {
public:
Transport(const PrinterData *printer_data);
~Transport();
void write(const void *buffer, size_t size) throw(TransportException);
bool check_abort() const;
const string &last_error() const;
protected:
void set_last_error(const char *e);
Transport(const Transport &);
Transport &operator = (const Transport &);
private:
image_id __image;
PFN_init_transport __init_transport;
PFN_exit_transport __exit_transport;
BDataIO *__data_stream;
bool __abort;
string __last_error_string;
};
#endif // __TRANSPORT_H
+34
View File
@@ -0,0 +1,34 @@
/*
* UIDriver.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __UIDRIVER_H
#define __UIDRIVER_H
class BMessage;
class PrinterData;
class PrinterCap;
class JobData;
class UIDriver {
public:
UIDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap);
virtual ~UIDriver();
BMessage *configPage();
BMessage *configJob();
protected:
virtual long doPageSetup(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
virtual long doJobSetup(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
UIDriver(const UIDriver &);
UIDriver &operator = (const UIDriver &);
private:
BMessage *__msg;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
};
#endif /* __UIDRIVER_H */
@@ -0,0 +1,24 @@
/*
* ValidRect.h
* Copyright 1999-2000 Y.Takagi All Rights Reserved.
*/
#ifndef __VALIDRECT_H
#define __VALIDRECT_H
#include <GraphicsDefs.h>
class BBitmap;
struct RECT {
int left;
int top;
int right;
int bottom;
};
bool get_valid_rect(BBitmap *bitmap, const rgb_color *palette, RECT *rc);
int color_space2pixel_depth(color_space cs);
#endif // __VALIDRECT_H