Some printing related improvements:
* libprint based drivers can now show a preview window and show progress window while printing contributed in part by Hartmut Reh. * Libprint and PCL6 driver bug fixes. * Code clean-up (removed code duplications, coding style, copyright text) Builds under Linux. Not tested under BeOS. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19882 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -36,8 +36,8 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef BEUTILS_H
|
||||
#define BEUTILS_H
|
||||
#ifndef _BE_UTILS_H
|
||||
#define _BE_UTILS_H
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
// mimetype from sender
|
||||
bool MimeTypeForSender(BMessage* sender, BString& mime);
|
||||
// adds fields to message or replaces existing fields
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL, const char* includeList[] = NULL);
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL, const char* includeList[] = NULL, bool overwrite = true);
|
||||
// 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!
|
||||
|
||||
@@ -27,6 +27,9 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PRINT_JOB_READER_H
|
||||
#define _PRINT_JOB_READER_H
|
||||
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
|
||||
@@ -80,3 +83,5 @@ public:
|
||||
status_t GetPage(int no, PrintJobPage& pjp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef PRINT_TRANSPORT_H
|
||||
#define PRINT_TRANSPORT_H
|
||||
#ifndef _PRINT_TRANSPORT_H
|
||||
#define _PRINT_TRANSPORT_H
|
||||
|
||||
#include <image.h>
|
||||
#include <DataIO.h>
|
||||
|
||||
@@ -27,8 +27,8 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef PRINT_TRANSPORT_ADD_ON_H
|
||||
#define PRINT_TRANSPORT_ADD_ON_H
|
||||
#ifndef _PRINT_TRANSPORT_ADD_ON_H
|
||||
#define _PRINT_TRANSPORT_ADD_ON_H
|
||||
|
||||
#include <image.h>
|
||||
#include <DataIO.h>
|
||||
@@ -38,4 +38,5 @@ THE SOFTWARE.
|
||||
// to be implemented by the transport add-on
|
||||
extern "C" BDataIO* instantiate_transport(BDirectory* printer, BMessage* msg);
|
||||
|
||||
#endif PRINT_TRANSPORT_ADD_ON_H
|
||||
#endif
|
||||
|
||||
|
||||
@@ -82,4 +82,4 @@ public:
|
||||
virtual void SetFontFace(int32 flags);
|
||||
};
|
||||
|
||||
#endif _TEMPLATE_H
|
||||
#endif // _TEMPLATE_H
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "PrintProcess.h"
|
||||
#include "SpoolMetaData.h"
|
||||
#include "Transport.h"
|
||||
#include "StatusWindow.h"
|
||||
|
||||
class BView;
|
||||
class BBitmap;
|
||||
@@ -26,7 +27,11 @@ class GraphicsDriver {
|
||||
public:
|
||||
GraphicsDriver(BMessage *, PrinterData *, const PrinterCap *);
|
||||
virtual ~GraphicsDriver();
|
||||
const JobData *getJobData(BFile *spoolFile);
|
||||
BMessage *takeJob(BFile *spool, uint32 flags = 0);
|
||||
static BPoint getScale(int32 nup, BRect physicalRect, float scaling);
|
||||
static BPoint getOffset(int32 nup, int index, JobData::Orientation orientation, const BPoint *scale,
|
||||
BRect scaledPhysicalRect, BRect scaledPrintableRect, BRect physicalRect);
|
||||
|
||||
protected:
|
||||
virtual bool startDoc();
|
||||
@@ -58,7 +63,7 @@ protected:
|
||||
GraphicsDriver &operator = (const GraphicsDriver &);
|
||||
|
||||
private:
|
||||
void setupData(BFile *file, long page_count);
|
||||
bool setupData(BFile *file);
|
||||
void setupBitmap();
|
||||
void cleanupData();
|
||||
void cleanupBitmap();
|
||||
@@ -91,6 +96,9 @@ private:
|
||||
int fPixelDepth;
|
||||
int fBandCount;
|
||||
int fInternalCopies;
|
||||
|
||||
uint32 fPageCount;
|
||||
StatusWindow *fStatusWindow;
|
||||
};
|
||||
|
||||
inline const JobData *GraphicsDriver::getJobData() const
|
||||
|
||||
@@ -206,7 +206,10 @@ public:
|
||||
*/
|
||||
enum Color {
|
||||
kMonochrome = 1,
|
||||
kColor
|
||||
kColor,
|
||||
// Some PCL6 printers do not support compressed data
|
||||
// in color mode.
|
||||
kColorCompressionDisabled
|
||||
};
|
||||
|
||||
enum Settings {
|
||||
@@ -221,6 +224,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
bool fShowPreview;
|
||||
Paper fPaper;
|
||||
int32 fXRes;
|
||||
int32 fYRes;
|
||||
@@ -261,6 +265,9 @@ public:
|
||||
void load(BMessage *msg, const PrinterCap *cap, Settings settings);
|
||||
void save(BMessage *msg = NULL);
|
||||
|
||||
bool getShowPreview() const { return fShowPreview; }
|
||||
void setShowPreview(bool showPreview) { fShowPreview = showPreview; }
|
||||
|
||||
Paper getPaper() const { return fPaper; }
|
||||
void setPaper(Paper paper) { fPaper = paper; }
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
bool UpdateJobData();
|
||||
bool UpdateJobData(bool showPreview);
|
||||
|
||||
private:
|
||||
void UpdateButtonEnabledState();
|
||||
|
||||
@@ -1,29 +1,139 @@
|
||||
/*
|
||||
* Preview.h
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
//#define USE_PREVIEW_FOR_DEBUG
|
||||
Preview
|
||||
|
||||
#ifdef USE_PREVIEW_FOR_DEBUG
|
||||
#ifndef __PREVIEW_H
|
||||
#define __PREVIEW_H
|
||||
Copyright (c) 2002, 2003 OpenBeOS.
|
||||
Copyright (c) 2005 Haiku.
|
||||
|
||||
#include <Window.h>
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
Hartmut Reh
|
||||
|
||||
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 <InterfaceKit.h>
|
||||
#include "PrintJobReader.h"
|
||||
#include "InterfaceUtils.h"
|
||||
|
||||
class PreviewPage {
|
||||
int32 fPage;
|
||||
int32 fNumberOfPictures;
|
||||
BPicture* fPictures;
|
||||
BPoint* fPoints;
|
||||
BRect* fRects;
|
||||
status_t fStatus;
|
||||
|
||||
class PreviewWindow : public BWindow {
|
||||
public:
|
||||
PreviewWindow(BRect, const char *, BBitmap *);
|
||||
virtual bool QuitRequested();
|
||||
int Go();
|
||||
PreviewPage(int32 page, PrintJobPage* pjp);
|
||||
~PreviewPage();
|
||||
status_t InitCheck() const;
|
||||
|
||||
protected:
|
||||
PreviewWindow(const PreviewWindow &);
|
||||
PreviewWindow &operator = (const PreviewWindow &);
|
||||
|
||||
private:
|
||||
long fSemaphore;
|
||||
int32 Page() const { return fPage; }
|
||||
void Draw(BView* view);
|
||||
};
|
||||
|
||||
class PreviewView : public BView {
|
||||
int32 fPage;
|
||||
int32 fZoom;
|
||||
PrintJobReader fReader;
|
||||
int32 fNumberOfPagesPerPage;
|
||||
int32 fNumberOfPages; // physical pages
|
||||
bool fReverse;
|
||||
BRect fPageRect;
|
||||
JobData::Orientation fOrientation;
|
||||
JobData::PageSelection fPageSelection;
|
||||
PreviewPage* fCachedPage;
|
||||
|
||||
float ZoomFactor() const;
|
||||
BRect PageRect() const;
|
||||
BRect PrintableRect() const;
|
||||
int32 GetPageNumber(int32 index) const;
|
||||
|
||||
public:
|
||||
PreviewView(BFile* jobFile, BRect rect);
|
||||
~PreviewView();
|
||||
status_t InitCheck() const;
|
||||
|
||||
BRect ViewRect() const;
|
||||
|
||||
bool IsPageLoaded(int32 page) const;
|
||||
bool IsPageValid() const;
|
||||
void LoadPage(int32 page);
|
||||
void DrawPageFrame(BRect r);
|
||||
void DrawPage(BRect r);
|
||||
void Draw(BRect r);
|
||||
void FrameResized(float width, float height);
|
||||
|
||||
void FixScrollbars();
|
||||
|
||||
bool ShowsFirstPage() const;
|
||||
bool ShowsLastPage() const;
|
||||
int CurrentPage() const { return fPage + 1; }
|
||||
int NumberOfPages() const;
|
||||
void ShowNextPage();
|
||||
void ShowPrevPage();
|
||||
void ShowFirstPage();
|
||||
void ShowLastPage();
|
||||
void ShowFindPage(int page);
|
||||
|
||||
bool CanZoomIn() const;
|
||||
bool CanZoomOut() const;
|
||||
void ZoomIn();
|
||||
void ZoomOut();
|
||||
};
|
||||
|
||||
class PreviewWindow : public BlockingWindow {
|
||||
BButton *fFirst;
|
||||
BButton *fNext;
|
||||
BButton *fPrev;
|
||||
BButton *fLast;
|
||||
BButton *fZoomIn;
|
||||
BButton *fZoomOut;
|
||||
BTextControl *fPageNumber;
|
||||
BStringView *fPageText;
|
||||
PreviewView *fPreview;
|
||||
BScrollView *fPreviewScroller;
|
||||
float fButtonBarHeight;
|
||||
|
||||
enum {
|
||||
MSG_FIRST_PAGE = 'pwfp',
|
||||
MSG_NEXT_PAGE = 'pwnp',
|
||||
MSG_PREV_PAGE = 'pwpp',
|
||||
MSG_LAST_PAGE = 'pwlp',
|
||||
MSG_FIND_PAGE = 'pwsp',
|
||||
MSG_ZOOM_IN = 'pwzi',
|
||||
MSG_ZOOM_OUT = 'pwzo',
|
||||
MSG_PRINT_JOB = 'pwpj',
|
||||
MSG_CANCEL_JOB = 'pwcj',
|
||||
};
|
||||
|
||||
void ResizeToPage(bool allowShrinking = false);
|
||||
void UpdateControls();
|
||||
|
||||
typedef BlockingWindow inherited;
|
||||
|
||||
public:
|
||||
PreviewWindow(BFile* jobFile, bool showOkAndCancelButtons = false);
|
||||
status_t InitCheck() const { return fPreview->InitCheck(); }
|
||||
void MessageReceived(BMessage* m);
|
||||
status_t Go();
|
||||
};
|
||||
|
||||
#endif /* __PREVIEW_H */
|
||||
#endif /* USE_PREVIEW_FOR_DEBUG */
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
StatusWindow.h
|
||||
Copyright 2005 Dr.H.Reh. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef STATUS_WINDOW_H
|
||||
#define STATUS_WINDOW_H
|
||||
|
||||
#ifndef _WINDOW_H
|
||||
#include <Window.h>
|
||||
#endif
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class StatusWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
StatusWindow(bool oddPages, bool evenPages,
|
||||
uint32 firstPage, uint32 numPages,
|
||||
uint32 docCopies, uint32 nup);
|
||||
~StatusWindow(void);
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
void ResetStatusBar(void);
|
||||
bool UpdateStatusBar(uint32 page, uint32 copy);
|
||||
void SetPageCopies(uint32 copies);
|
||||
|
||||
private:
|
||||
BView *fStatusView;
|
||||
BStatusBar *fStatusBar;
|
||||
BButton *fCancelButton;
|
||||
BButton *fHideButton;
|
||||
bool fCancelBar;
|
||||
bool fDocumentCopy;
|
||||
uint32 fNops;
|
||||
uint32 fFirstPage;
|
||||
uint32 fCopies;
|
||||
uint32 fDocCopies;
|
||||
float fStatusDelta;
|
||||
float fDelta;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+5
-4
@@ -32,10 +32,6 @@ THE SOFTWARE.
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
|
||||
// Text to be displayed in About window, declared in the application
|
||||
// that uses HWindow class!!!
|
||||
extern const char* kAbout;
|
||||
|
||||
// --------------------------------------------------
|
||||
class HWindow : public BWindow
|
||||
{
|
||||
@@ -50,6 +46,7 @@ public:
|
||||
|
||||
virtual void MessageReceived(BMessage* m);
|
||||
virtual void AboutRequested();
|
||||
virtual const char* AboutText() const { return NULL; }
|
||||
};
|
||||
|
||||
// --------------------------------------------------
|
||||
@@ -67,12 +64,16 @@ public:
|
||||
virtual status_t Go();
|
||||
// Or quit window e.g. something went wrong in constructor
|
||||
void Quit();
|
||||
// Sets the result that is returned when the user closes the window.
|
||||
// Default is B_OK.
|
||||
void SetUserQuitResult(status_t result);
|
||||
|
||||
typedef HWindow inherited;
|
||||
|
||||
private:
|
||||
void Init(const char* title);
|
||||
|
||||
status_t fUserQuitResult;
|
||||
bool fReadyToQuit;
|
||||
sem_id fExitSem;
|
||||
status_t* fResult;
|
||||
+3
-3
@@ -118,8 +118,8 @@ THE SOFTWARE.
|
||||
kUnitPoint, 1 point/point
|
||||
*/
|
||||
|
||||
#ifndef MARGIN_VIEW_H
|
||||
#define MARGIN_VIEW_H
|
||||
#ifndef _MARGIN_VIEW_H
|
||||
#define _MARGIN_VIEW_H
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <Looper.h>
|
||||
@@ -222,4 +222,4 @@ public:
|
||||
void MessageReceived(BMessage *msg);
|
||||
};
|
||||
|
||||
#endif //MARGIN_VIEW_H
|
||||
#endif // _MARGIN_VIEW_H
|
||||
@@ -38,8 +38,6 @@ THE SOFTWARE.
|
||||
#include <MessageFilter.h>
|
||||
|
||||
|
||||
// adds fields to message or replaces existing fields (copy BeUtils.h)
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL, const char* includeList[] = NULL);
|
||||
void AddString(BMessage* m, const char* name, const char* value);
|
||||
|
||||
// set or replace a value in a BMessage
|
||||
@@ -47,9 +45,6 @@ void SetRect(BMessage* msg, const char* name, BRect rect);
|
||||
void SetFloat(BMessage* msg, const char* name, float value);
|
||||
void SetInt32(BMessage* msg, const char* name, int32 value);
|
||||
|
||||
// scalar multiplication
|
||||
BRect ScaleRect(BRect rect, float scale);
|
||||
|
||||
class EscapeMessageFilter : public BMessageFilter
|
||||
{
|
||||
private:
|
||||
@@ -134,30 +129,4 @@ void TList<T>::SortItems(int (*comp)(const T**, const T**)) {
|
||||
fList.SortItems(sort);
|
||||
}
|
||||
|
||||
// PDF coordinate system
|
||||
class PDFSystem {
|
||||
private:
|
||||
float fHeight;
|
||||
float fX;
|
||||
float fY;
|
||||
float fScale;
|
||||
|
||||
public:
|
||||
PDFSystem()
|
||||
: fHeight(0), fX(0), fY(0), fScale(1) { }
|
||||
PDFSystem(float h, float x, float y, float s)
|
||||
: fHeight(h), fX(x), fY(y), fScale(s) { }
|
||||
|
||||
void SetHeight(float h) { fHeight = h; }
|
||||
void SetOrigin(float x, float y) { fX = x; fY = y; }
|
||||
void SetScale(float scale) { fScale = scale; }
|
||||
float Height() const { return fHeight; }
|
||||
BPoint Origin() const { return BPoint(fX, fY); }
|
||||
float Scale() const { return fScale; }
|
||||
|
||||
inline float tx(float x) { return fX + fScale*x; }
|
||||
inline float ty(float y) { return fHeight - (fY + fScale * y); }
|
||||
inline float scale(float f) { return fScale * f; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers canon_lips lips3 ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
AddResources Canon\ LIPS3\ Compatible : Lips3.rdef ;
|
||||
|
||||
@@ -13,7 +14,11 @@ Addon Canon\ LIPS3\ Compatible : Print :
|
||||
Compress3.cpp
|
||||
;
|
||||
|
||||
LinkAgainst Canon\ LIPS3\ Compatible : be libprint.a $(TARGET_LIBSTDC++) ;
|
||||
LinkAgainst Canon\ LIPS3\ Compatible :
|
||||
be
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
$(TARGET_LIBSTDC++) ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
Canon\ LIPS3\ Compatible :
|
||||
|
||||
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers canon_lips lips4 ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
AddResources Canon\ LIPS4\ Compatible : Lips4.rdef ;
|
||||
|
||||
@@ -12,7 +13,11 @@ Addon Canon\ LIPS4\ Compatible : Print :
|
||||
Lips4Cap.cpp
|
||||
;
|
||||
|
||||
LinkAgainst Canon\ LIPS4\ Compatible : be libprint.a $(TARGET_LIBSTDC++) ;
|
||||
LinkAgainst Canon\ LIPS4\ Compatible :
|
||||
be
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
$(TARGET_LIBSTDC++) ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
Canon\ LIPS4\ Compatible :
|
||||
|
||||
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers pcl5 ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
AddResources PCL5\ Compatible : PCL5.rsrc ;
|
||||
|
||||
@@ -12,7 +13,11 @@ Addon PCL5\ Compatible : Print :
|
||||
PCL5Cap.cpp
|
||||
;
|
||||
|
||||
LinkAgainst PCL5\ Compatible : be libprint.a $(TARGET_LIBSTDC++) ;
|
||||
LinkAgainst PCL5\ Compatible :
|
||||
be
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
$(TARGET_LIBSTDC++) ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
PCL5\ Compatible :
|
||||
|
||||
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers pcl6 ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
AddResources PCL6\ Compatible : PCL6.rsrc ;
|
||||
|
||||
@@ -16,9 +17,11 @@ Addon PCL6\ Compatible : Print :
|
||||
Rasterizer.cpp
|
||||
;
|
||||
|
||||
ObjectC++Flags [ FGristFiles jetlib.o ] : -w ;
|
||||
|
||||
LinkAgainst PCL6\ Compatible : be libprint.a $(TARGET_LIBSTDC++) ;
|
||||
LinkAgainst PCL6\ Compatible :
|
||||
be
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
$(TARGET_LIBSTDC++) ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
PCL6\ Compatible :
|
||||
|
||||
@@ -97,7 +97,7 @@ bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
int y = (int)offset->y;
|
||||
|
||||
PCL6Rasterizer *rasterizer;
|
||||
if (getJobData()->getColor() == JobData::kColor) {
|
||||
if (useColorMode()) {
|
||||
#if COLOR_DEPTH == 8
|
||||
rasterizer = new ColorRGBRasterizer(fHalftone);
|
||||
#elif COLOR_DEPTH == 1
|
||||
@@ -179,11 +179,13 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
||||
#endif
|
||||
|
||||
#if ENABLE_RLE_COMPRESSION
|
||||
if (supportsRLECompression()) {
|
||||
int rleSize = pack_bits_size(buffer, outSize);
|
||||
if (rleSize < dataSize) {
|
||||
compressionMethod = PCL6Writer::kRLECompression;
|
||||
dataSize = rleSize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// write bitmap
|
||||
@@ -246,9 +248,8 @@ bool PCL6Driver::startPage(int)
|
||||
// PageOrigin from Windows NT printer driver
|
||||
int x = 142 * getJobData()->getXres() / 600;
|
||||
int y = 100 * getJobData()->getYres() / 600;
|
||||
bool color = getJobData()->getColor() == JobData::kColor;
|
||||
fWriter->SetPageOrigin(x, y);
|
||||
fWriter->SetColorSpace(color ? PCL6Writer::kRGB : PCL6Writer::kGray);
|
||||
fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB : PCL6Writer::kGray);
|
||||
fWriter->SetPaintTxMode(PCL6Writer::kOpaque);
|
||||
fWriter->SetSourceTxMode(PCL6Writer::kOpaque);
|
||||
fWriter->SetROP(204);
|
||||
@@ -257,9 +258,8 @@ bool PCL6Driver::startPage(int)
|
||||
|
||||
void PCL6Driver::startRasterGraphics(int x, int y, int width, int height, PCL6Writer::Compression compressionMethod)
|
||||
{
|
||||
bool color = getJobData()->getColor() == JobData::kColor;
|
||||
PCL6Writer::ColorDepth colorDepth;
|
||||
if (color) {
|
||||
if (useColorMode()) {
|
||||
#if COLOR_DEPTH == 8
|
||||
colorDepth = PCL6Writer::k8Bit;
|
||||
#elif COLOR_DEPTH == 1
|
||||
@@ -351,10 +351,23 @@ void PCL6Driver::move(int x, int y)
|
||||
fWriter->SetCursor(x, y);
|
||||
}
|
||||
|
||||
bool
|
||||
PCL6Driver::supportsRLECompression()
|
||||
{
|
||||
return getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
||||
}
|
||||
|
||||
bool
|
||||
PCL6Driver::supportsDeltaRowCompression()
|
||||
{
|
||||
return getProtocolClass() >= PCL6Writer::kProtocolClass2_1;
|
||||
return getProtocolClass() >= PCL6Writer::kProtocolClass2_1 &&
|
||||
getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
||||
}
|
||||
|
||||
bool
|
||||
PCL6Driver::useColorMode()
|
||||
{
|
||||
return getJobData()->getColor() != JobData::kMonochrome;
|
||||
}
|
||||
|
||||
PCL6Writer::MediaSize PCL6Driver::mediaSize(JobData::Paper paper)
|
||||
|
||||
@@ -29,7 +29,9 @@ protected:
|
||||
virtual bool endDoc(bool success);
|
||||
|
||||
private:
|
||||
bool supportsRLECompression();
|
||||
bool supportsDeltaRowCompression();
|
||||
bool useColorMode();
|
||||
PCL6Writer::MediaSize mediaSize(JobData::Paper paper);
|
||||
PCL6Writer::MediaSource mediaSource(JobData::PaperSource source);
|
||||
void move(int x, int y);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PCL6Cap.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
* COpyright 2003-2005 Michael Pfeiffer.
|
||||
* Copyright 2003-2007 Michael Pfeiffer.
|
||||
*/
|
||||
|
||||
#include "PCL6Cap.h"
|
||||
@@ -247,10 +247,12 @@ const ProtocolClassCap *protocolClasses[] = {
|
||||
};
|
||||
|
||||
const ColorCap color("Color", false, JobData::kColor);
|
||||
const ColorCap colorCompressionDisabled("Color (No Compression)", false, JobData::kColorCompressionDisabled);
|
||||
const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome);
|
||||
|
||||
const ColorCap *colors[] = {
|
||||
&color,
|
||||
&colorCompressionDisabled,
|
||||
&monochrome
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
// Run-Length-Encoding Compression
|
||||
#define ENABLE_RLE_COMPRESSION 1
|
||||
//#define ENABLE_RLE_COMPRESSION 0
|
||||
|
||||
// Delta Row Compression
|
||||
#define ENABLE_DELTA_ROW_COMPRESSION 1
|
||||
@@ -21,6 +22,7 @@
|
||||
// If 1 bit depth is used, the class Halftone is used for dithering
|
||||
// otherwise dithering is not performed.
|
||||
#define COLOR_DEPTH 1
|
||||
//#define COLOR_DEPTH 8
|
||||
|
||||
#define DISPLAY_COMPRESSION_STATISTICS 0
|
||||
|
||||
|
||||
@@ -48,3 +48,4 @@ PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
|
||||
{
|
||||
return new PCL6PrinterDriver(printerFolder);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
|
||||
AboutText.cpp
|
||||
|
||||
Copyright (c) 2001-2006 Haiku.
|
||||
|
||||
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 <InterfaceDefs.h>
|
||||
|
||||
static const char*
|
||||
kAbout =
|
||||
"PDF Writer for BeOS\n"
|
||||
B_UTF8_COPYRIGHT " 2001-2004 Haiku\n"
|
||||
"\n"
|
||||
"Philippe Houdoin\n"
|
||||
"\tProject Leader\n\n"
|
||||
"Simon Gauvin\n"
|
||||
"\tGUI Design\n\n"
|
||||
"Michael Pfeiffer\n"
|
||||
"\tPDF Generation\n"
|
||||
"\tConfiguration\n"
|
||||
"\tInteractive Features\n"
|
||||
"\t" B_UTF8_ELLIPSIS
|
||||
;
|
||||
@@ -1,291 +0,0 @@
|
||||
/*
|
||||
|
||||
InterfaceUtils.cpp
|
||||
|
||||
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 <string.h>
|
||||
#include "InterfaceUtils.h"
|
||||
#include "Utils.h"
|
||||
|
||||
// Implementation of HWindow
|
||||
|
||||
// --------------------------------------------------
|
||||
HWindow::HWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace, uint32 escape_msg)
|
||||
: BWindow(frame, title, type, flags, workspace)
|
||||
{
|
||||
Init(escape_msg);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
HWindow::HWindow(BRect frame, const char *title, window_look look, window_feel feel, uint32 flags, uint32 workspace, uint32 escape_msg)
|
||||
: BWindow(frame, title, look, feel, flags, workspace)
|
||||
{
|
||||
Init(escape_msg);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
HWindow::Init(uint32 escape_msg)
|
||||
{
|
||||
AddShortcut('i', 0, new BMessage(B_ABOUT_REQUESTED));
|
||||
AddCommonFilter(new EscapeMessageFilter(this, escape_msg));
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
HWindow::MessageReceived(BMessage* msg)
|
||||
{
|
||||
if (msg->what == B_ABOUT_REQUESTED) {
|
||||
AboutRequested();
|
||||
} else {
|
||||
inherited::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
static const char*
|
||||
kAbout =
|
||||
"PDF Writer for BeOS\n"
|
||||
B_UTF8_COPYRIGHT " 2001-2004 Haiku\n"
|
||||
"\n"
|
||||
"Philippe Houdoin\n"
|
||||
"\tProject Leader\n\n"
|
||||
"Simon Gauvin\n"
|
||||
"\tGUI Design\n\n"
|
||||
"Michael Pfeiffer\n"
|
||||
"\tPDF Generation\n"
|
||||
"\tConfiguration\n"
|
||||
"\tInteractive Features\n"
|
||||
"\t" B_UTF8_ELLIPSIS
|
||||
;
|
||||
|
||||
void
|
||||
HWindow::AboutRequested()
|
||||
{
|
||||
BAlert *about = new BAlert("About PDF Writer", kAbout, "Cool");
|
||||
BTextView *v = about->TextView();
|
||||
if (v) {
|
||||
// Colors grab with Magnify on BeOS R5 deskbar logo
|
||||
rgb_color red = {203, 0, 51, 255};
|
||||
rgb_color blue = {0, 51, 152, 255};
|
||||
|
||||
v->SetStylable(true);
|
||||
char *text = (char*) v->Text();
|
||||
char *s = text;
|
||||
|
||||
// set first line 16pt bold
|
||||
s = strchr(text, '\n');
|
||||
BFont font(be_bold_font);
|
||||
font.SetSize(16); // font.SetFace(B_OUTLINED_FACE);
|
||||
v->SetFontAndColor(0, s-text, &font);
|
||||
|
||||
// set all Be in blue and red
|
||||
s = text;
|
||||
while ((s = strstr(s, "BeOS")) != NULL) {
|
||||
int32 i = s - text;
|
||||
v->SetFontAndColor(i, i+2, NULL, 0, &blue);
|
||||
v->SetFontAndColor(i+2, i+4, NULL, 0, &red);
|
||||
s += 2;
|
||||
}
|
||||
};
|
||||
about->Go();
|
||||
}
|
||||
|
||||
|
||||
// Impelementation of TextView
|
||||
|
||||
// --------------------------------------------------
|
||||
TextView::TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
uint32 rmask,
|
||||
uint32 flags)
|
||||
: BTextView(frame, name, textRect, rmask, flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
TextView::TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
const BFont *font, const rgb_color *color,
|
||||
uint32 rmask,
|
||||
uint32 flags)
|
||||
: BTextView(frame, name, textRect, font, color, rmask, flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
TextView::KeyDown(const char *bytes, int32 numBytes)
|
||||
{
|
||||
if (numBytes == 1 && *bytes == B_TAB) {
|
||||
BView::KeyDown(bytes, numBytes);
|
||||
return;
|
||||
}
|
||||
inherited::KeyDown(bytes, numBytes);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
TextView::Draw(BRect update)
|
||||
{
|
||||
inherited::Draw(update);
|
||||
if (IsFocus()) {
|
||||
// stroke focus rectangle
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
StrokeRect(Bounds());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
TextView::MakeFocus(bool focus)
|
||||
{
|
||||
Invalidate();
|
||||
inherited::MakeFocus(focus);
|
||||
// notify TextControl
|
||||
BView* parent = Parent(); // BBox
|
||||
if (focus && parent) {
|
||||
parent = parent->Parent(); // TextControl
|
||||
TextControl* control = dynamic_cast<TextControl*>(parent);
|
||||
if (control) control->FocusSetTo(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Impelementation of TextControl
|
||||
|
||||
// --------------------------------------------------
|
||||
TextControl::TextControl(BRect frame,
|
||||
const char *name,
|
||||
const char *label,
|
||||
const char *initial_text,
|
||||
BMessage *message,
|
||||
uint32 rmask,
|
||||
uint32 flags)
|
||||
: BView(frame, name, rmask, flags)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
BRect r(0, 0, frame.Width() / 2 -1, frame.Height());
|
||||
fLabel = new BStringView(r, "", label);
|
||||
BRect f(r);
|
||||
f.OffsetTo(frame.Width() / 2 + 1, 0);
|
||||
// box around TextView
|
||||
BBox *box = new BBox(f, "", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
f.OffsetTo(0, 0);
|
||||
f.InsetBy(1,1);
|
||||
r.InsetBy(2,2);
|
||||
fText = new TextView(f, "", r, rmask, flags | B_NAVIGABLE);
|
||||
fText->SetWordWrap(false);
|
||||
fText->DisallowChar('\n');
|
||||
fText->Insert(initial_text);
|
||||
AddChild(fLabel);
|
||||
AddChild(box);
|
||||
box->AddChild(fText);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
TextControl::ConvertToParent(BView* parent, BView* child, BRect &rect)
|
||||
{
|
||||
do {
|
||||
child->ConvertToParent(&rect);
|
||||
child = child->Parent();
|
||||
} while (child != NULL && child != parent);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
TextControl::FocusSetTo(BView *child)
|
||||
{
|
||||
BRect r;
|
||||
BView* parent = Parent(); // Table
|
||||
if (parent) {
|
||||
ConvertToParent(parent, child, r);
|
||||
parent->ScrollTo(0, r.top);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Impelementation of Implementation of Table
|
||||
|
||||
// --------------------------------------------------
|
||||
Table::Table(BRect frame, const char *name, uint32 rmode, uint32 flags)
|
||||
: BView(frame, name, rmode, flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
Table::ScrollTo(BPoint p)
|
||||
{
|
||||
float h = Frame().Height()+1;
|
||||
if (Parent()) {
|
||||
BScrollView* scrollView = dynamic_cast<BScrollView*>(Parent());
|
||||
if (scrollView) {
|
||||
BScrollBar *sb = scrollView->ScrollBar(B_VERTICAL);
|
||||
float min, max;
|
||||
sb->GetRange(&min, &max);
|
||||
if (p.y < (h/2)) p.y = 0;
|
||||
else if (p.y > max) p.y = max;
|
||||
}
|
||||
}
|
||||
inherited::ScrollTo(p);
|
||||
}
|
||||
|
||||
|
||||
// Impelementation of DragListView
|
||||
|
||||
// --------------------------------------------------
|
||||
DragListView::DragListView(BRect frame, const char *name,
|
||||
list_view_type type,
|
||||
uint32 resizingMode, uint32 flags)
|
||||
: BListView(frame, name, type, resizingMode, flags)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
bool DragListView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
|
||||
{
|
||||
BMessage m;
|
||||
DragMessage(&m, ItemFrame(index), this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
|
||||
InterfaceUtils.cpp
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _INTERFACE_UTILS_H
|
||||
#define _INTERFACE_UTILS_H
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
|
||||
// --------------------------------------------------
|
||||
class HWindow : public BWindow
|
||||
{
|
||||
protected:
|
||||
void Init(uint32 escape_msg);
|
||||
|
||||
public:
|
||||
typedef BWindow inherited;
|
||||
|
||||
HWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
HWindow(BRect frame, const char *title, window_look look, window_feel feel, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE, uint32 escape_msg = B_QUIT_REQUESTED);
|
||||
|
||||
virtual void MessageReceived(BMessage* m);
|
||||
virtual void AboutRequested();
|
||||
};
|
||||
|
||||
// --------------------------------------------------
|
||||
class TextView : public BTextView
|
||||
{
|
||||
public:
|
||||
typedef BTextView inherited;
|
||||
|
||||
TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
TextView(BRect frame,
|
||||
const char *name,
|
||||
BRect textRect,
|
||||
const BFont *font, const rgb_color *color,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
void KeyDown(const char *bytes, int32 numBytes);
|
||||
void MakeFocus(bool focus = true);
|
||||
void Draw(BRect r);
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
class TextControl : public BView
|
||||
{
|
||||
BStringView *fLabel;
|
||||
TextView *fText;
|
||||
public:
|
||||
TextControl(BRect frame,
|
||||
const char *name,
|
||||
const char *label,
|
||||
const char *initial_text,
|
||||
BMessage *message,
|
||||
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
const char *Label() { return fLabel->Text(); }
|
||||
const char *Text() { return fText->Text(); }
|
||||
void MakeFocus(bool focus = true) { fText->MakeFocus(focus); }
|
||||
void ConvertToParent(BView* parent, BView* child, BRect &rect);
|
||||
void FocusSetTo(BView* child);
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
class Table : public BView
|
||||
{
|
||||
public:
|
||||
typedef BView inherited;
|
||||
|
||||
Table(BRect frame, const char *name, uint32 rmode, uint32 flags);
|
||||
void ScrollTo(BPoint p);
|
||||
};
|
||||
|
||||
class DragListView : public BListView
|
||||
{
|
||||
public:
|
||||
DragListView(BRect frame, const char *name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS);
|
||||
bool InitiateDrag(BPoint point, int32 index, bool wasSelected);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,7 @@ SubDir HAIKU_TOP src add-ons print drivers pdf source ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders interface print ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) src libs pdflib libs pdflib ] ;
|
||||
|
||||
AddResources PDF\ Writer :
|
||||
@@ -11,6 +10,7 @@ AddResources PDF\ Writer :
|
||||
;
|
||||
|
||||
Addon PDF\ Writer : Print :
|
||||
AboutText.cpp
|
||||
AdvancedSettingsWindow.cpp
|
||||
Bezier.cpp
|
||||
Bookmark.cpp
|
||||
@@ -22,7 +22,6 @@ Addon PDF\ Writer : Print :
|
||||
FontsWindow.cpp
|
||||
Image.cpp
|
||||
ImageCache.cpp
|
||||
InterfaceUtils.cpp
|
||||
JobSetupWindow.cpp
|
||||
LinePathBuilder.cpp
|
||||
Link.cpp
|
||||
@@ -42,7 +41,6 @@ Addon PDF\ Writer : Print :
|
||||
Scanner.cpp
|
||||
StatusWindow.cpp
|
||||
SubPath.cpp
|
||||
Utils.cpp
|
||||
XReferences.cpp
|
||||
;
|
||||
|
||||
@@ -51,7 +49,7 @@ LinkAgainst PDF\ Writer :
|
||||
textencoding
|
||||
translation
|
||||
libpdf.a
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
;
|
||||
|
||||
Package haiku-pdf_writer-cvs :
|
||||
|
||||
@@ -33,6 +33,8 @@ THE SOFTWARE.
|
||||
#include <SupportKit.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "BeUtils.h"
|
||||
|
||||
#include "PrinterDriver.h"
|
||||
#include "JobSetupWindow.h"
|
||||
#include "DocInfoWindow.h"
|
||||
@@ -89,7 +91,7 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
doc_info.AddString("Keywords", "");
|
||||
fSetupMsg->AddMessage("doc_info", &doc_info);
|
||||
}
|
||||
AddFields(&fDocInfo, fSetupMsg, true, NULL, includeKeys);
|
||||
AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
|
||||
|
||||
allPages = firstPage == 1 && lastPage == MAX_INT32;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ THE SOFTWARE.
|
||||
#include "Link.h"
|
||||
#include "XReferences.h"
|
||||
#include "Bookmark.h"
|
||||
#include "PDFSystem.h"
|
||||
#include "PDFWriter.h"
|
||||
#include "Log.h"
|
||||
#include "Report.h"
|
||||
|
||||
@@ -34,7 +34,9 @@ THE SOFTWARE.
|
||||
#include <Font.h>
|
||||
#include <Point.h>
|
||||
#include "Utils.h"
|
||||
#include "PDFSystem.h"
|
||||
|
||||
class PDFSystem;
|
||||
class PDFWriter;
|
||||
|
||||
class TextLine;
|
||||
|
||||
+3
-95
@@ -3,6 +3,7 @@
|
||||
PDF Writer printer driver.
|
||||
|
||||
Copyright (c) 2001-2003 OpenBeOS.
|
||||
Copyright (c) 2006 Haiku.
|
||||
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
@@ -29,101 +30,8 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _UTILS_H
|
||||
#define _UTILS_H
|
||||
|
||||
#include <Window.h>
|
||||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
|
||||
|
||||
// adds fields to message or replaces existing fields (copy BeUtils.h)
|
||||
void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const char* excludeList[] = NULL, const char* includeList[] = NULL);
|
||||
void AddString(BMessage* m, const char* name, const char* value);
|
||||
|
||||
class EscapeMessageFilter : public BMessageFilter
|
||||
{
|
||||
private:
|
||||
BWindow *fWindow;
|
||||
int32 fWhat;
|
||||
|
||||
public:
|
||||
EscapeMessageFilter(BWindow *window, int32 what);
|
||||
filter_result Filter(BMessage *msg, BHandler **target);
|
||||
};
|
||||
|
||||
|
||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) != 0x80)
|
||||
|
||||
|
||||
template <class T>
|
||||
class TList {
|
||||
private:
|
||||
BList fList;
|
||||
typedef int (*sort_func)(const void*, const void*);
|
||||
|
||||
public:
|
||||
virtual ~TList();
|
||||
void MakeEmpty();
|
||||
int32 CountItems() const;
|
||||
T* ItemAt(int32 index) const;
|
||||
void AddItem(T* p);
|
||||
T* RemoveItem(int i);
|
||||
T* Items();
|
||||
void SortItems(int (*comp)(const T**, const T**));
|
||||
};
|
||||
|
||||
// TList
|
||||
template<class T>
|
||||
TList<T>::~TList() {
|
||||
MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::MakeEmpty() {
|
||||
const int32 n = CountItems();
|
||||
for (int i = 0; i < n; i++) {
|
||||
delete ItemAt(i);
|
||||
}
|
||||
fList.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
int32 TList<T>::CountItems() const {
|
||||
return fList.CountItems();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::ItemAt(int32 index) const {
|
||||
return (T*)fList.ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::AddItem(T* p) {
|
||||
fList.AddItem(p);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::RemoveItem(int i) {
|
||||
return (T*)fList.RemoveItem(i);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T* TList<T>::Items() {
|
||||
return (T*)fList.Items();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void TList<T>::SortItems(int (*comp)(const T**, const T**)) {
|
||||
sort_func sort = (sort_func)comp;
|
||||
fList.SortItems(sort);
|
||||
}
|
||||
#ifndef _PDF_SYSTEM_H
|
||||
#define _PDF_SYSTEM_H
|
||||
|
||||
// PDF coordinate system
|
||||
class PDFSystem {
|
||||
@@ -46,6 +46,7 @@ THE SOFTWARE.
|
||||
#include "Utils.h"
|
||||
#include "Link.h"
|
||||
#include "ImageCache.h"
|
||||
#include "PDFSystem.h"
|
||||
|
||||
#include "pdflib.h"
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ PrinterDriver::PrintJob
|
||||
Report::Instance();
|
||||
|
||||
// show status window
|
||||
fStatusWindow = new StatusWindow(passes, pfh.page_count, this);
|
||||
StatusWindow* statusWindow = new StatusWindow(passes, pfh.page_count, this);
|
||||
|
||||
status = BeginJob();
|
||||
|
||||
@@ -146,7 +146,7 @@ PrinterDriver::PrintJob
|
||||
for (copy = 0; copy < copies && status == B_OK && fPrinting; copy++)
|
||||
{
|
||||
for (page = 1; page <= pfh.page_count && status == B_OK && fPrinting; page++) {
|
||||
fStatusWindow->PostMessage(new BMessage('page'));
|
||||
statusWindow->NextPage();
|
||||
status = PrintPage(page, pfh.page_count);
|
||||
}
|
||||
|
||||
@@ -163,10 +163,10 @@ PrinterDriver::PrintJob
|
||||
|
||||
// close status window
|
||||
if (Report::Instance()->CountItems() != 0) {
|
||||
fStatusWindow->WaitForClose();
|
||||
statusWindow->WaitForClose();
|
||||
}
|
||||
if (fStatusWindow->Lock()) {
|
||||
fStatusWindow->Quit();
|
||||
if (statusWindow->Lock()) {
|
||||
statusWindow->Quit();
|
||||
}
|
||||
|
||||
// delete Report object
|
||||
|
||||
@@ -29,8 +29,8 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef PRINTERDRIVER_H
|
||||
#define PRINTERDRIVER_H
|
||||
#ifndef _PRINTER_DRIVER_H
|
||||
#define _PRINTER_DRIVER_H
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <InterfaceKit.h>
|
||||
@@ -50,8 +50,6 @@ extern "C" {
|
||||
};
|
||||
|
||||
|
||||
class StatusWindow;
|
||||
|
||||
// close StatusWindow after pdf generation
|
||||
enum CloseOption {
|
||||
kAlways,
|
||||
@@ -90,7 +88,6 @@ public:
|
||||
inline BNode *PrinterNode() { return fPrinterNode; }
|
||||
inline BMessage *JobMsg() { return fJobMsg; }
|
||||
inline BDataIO *Transport() { return fPrintTransport.GetDataIO(); }
|
||||
inline StatusWindow *Status() { return fStatusWindow; }
|
||||
inline int32 Pass() const { return fPass; }
|
||||
|
||||
// publics status code
|
||||
@@ -104,7 +101,6 @@ private:
|
||||
BFile *fJobFile;
|
||||
BNode *fPrinterNode;
|
||||
BMessage *fJobMsg;
|
||||
StatusWindow *fStatusWindow;
|
||||
|
||||
volatile Orientation fOrientation;
|
||||
|
||||
@@ -115,4 +111,4 @@ private:
|
||||
PrintTransport fPrintTransport;
|
||||
};
|
||||
|
||||
#endif // #ifndef PRINTERDRIVER_H
|
||||
#endif // _PRINTER_DRIVER_H
|
||||
|
||||
@@ -29,14 +29,13 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef PRINTER_SETTINGS_H
|
||||
#include "PrinterSettings.h"
|
||||
#endif
|
||||
|
||||
#include <fs_attr.h>
|
||||
|
||||
#include "BeUtils.h"
|
||||
|
||||
#include "PrinterPrefs.h"
|
||||
#include "Utils.h"
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -283,7 +282,7 @@ PrinterSettings::Read(BNode* node, BMessage* msg, Kind kind)
|
||||
// if there were none, then create a default set...
|
||||
ps.GetDefaults(&settings);
|
||||
}
|
||||
AddFields(msg, &settings, false);
|
||||
AddFields(msg, &settings, NULL, NULL, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -34,19 +34,20 @@ THE SOFTWARE.
|
||||
#include <Message.h>
|
||||
#include <Box.h>
|
||||
|
||||
static const uint32 kCancelMsg = 'cncl';
|
||||
static const uint32 kProgressMsg = 'prgs';
|
||||
|
||||
// --------------------------------------------------
|
||||
StatusWindow::StatusWindow(int32 passes, int32 pages, PrinterDriver *pd)
|
||||
: HWindow(BRect(100, 100, 700, 600/*400, 185*/), "PDF Writer",
|
||||
: HWindow(BRect(100, 100, 700, 600), "PDF Writer",
|
||||
B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_NOT_CLOSABLE|B_FRAME_EVENTS,
|
||||
B_CURRENT_WORKSPACE, 'cncl')
|
||||
B_CURRENT_WORKSPACE, kCancelMsg)
|
||||
{
|
||||
fPass = 0;
|
||||
fPages = pages;
|
||||
fPrinterDriver = pd;
|
||||
fPageCount = 0;
|
||||
// fPopyCount = 0;
|
||||
fReportIndex = 0;
|
||||
fCloseSem = -1;
|
||||
int32 closeOption;
|
||||
@@ -61,21 +62,7 @@ StatusWindow::StatusWindow(int32 passes, int32 pages, PrinterDriver *pd)
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||
B_PLAIN_BORDER);
|
||||
AddChild(fPanel);
|
||||
/*
|
||||
if (fCopies > 1) {
|
||||
pages *= fCopies;
|
||||
}
|
||||
|
||||
r.Set(10, 0, Frame().Width(), 50);
|
||||
copyLabel = new BStringView(r, "copy_text", "Copy");
|
||||
panel->AddChild(copyLabel);
|
||||
|
||||
r.Set(10, 55, Frame().Width()-20, 65);
|
||||
copyStatus = new BStatusBar(r, "copyStatus");
|
||||
copyStatus->SetMaxValue(copies);
|
||||
copyStatus->SetBarHeight(12);
|
||||
panel->AddChild(copyStatus);
|
||||
*/
|
||||
r.Set(10, 12, Frame().Width()-5, 22);
|
||||
fPageLabel = new BStringView(r, "page_text", "Page", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||
fPanel->AddChild(fPageLabel);
|
||||
@@ -86,17 +73,11 @@ StatusWindow::StatusWindow(int32 passes, int32 pages, PrinterDriver *pd)
|
||||
fPageStatus->SetBarHeight(12);
|
||||
fPanel->AddChild(fPageStatus);
|
||||
|
||||
// Cancel button
|
||||
// add a separator line...
|
||||
// BBox *line = new BBox(BRect(r.left, 50, r.right, 51), NULL,
|
||||
// B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
|
||||
// panel->AddChild(line);
|
||||
|
||||
// add a "Cancel" button
|
||||
int32 x = 110;
|
||||
int32 y = 55;
|
||||
fCancel = new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel",
|
||||
new BMessage('cncl'), B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
new BMessage(kCancelMsg), B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
fCancel->ResizeToPreferred();
|
||||
fPanel->AddChild(fCancel);
|
||||
|
||||
@@ -107,7 +88,6 @@ StatusWindow::StatusWindow(int32 passes, int32 pages, PrinterDriver *pd)
|
||||
fReport->SetStylable(true);
|
||||
fReport->MakeEditable(false);
|
||||
fPanel->AddChild(new BScrollView("", fReport, B_FOLLOW_ALL, 0, false, true));
|
||||
// fPanel->AddChild(fReport);
|
||||
|
||||
ResizeTo(300, 85);
|
||||
|
||||
@@ -119,15 +99,7 @@ void
|
||||
StatusWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
/*
|
||||
case 'copy':
|
||||
copy = "";
|
||||
copy << "Copy: " << ++copyCount;
|
||||
copyLabel->SetText(copy.String());
|
||||
copyStatus->Update(1);
|
||||
break;
|
||||
*/
|
||||
case 'cncl':
|
||||
case kCancelMsg:
|
||||
if (fCloseSem == -1) {
|
||||
fPrinterDriver->StopPrinting();
|
||||
fCancel->SetEnabled(false);
|
||||
@@ -136,7 +108,8 @@ StatusWindow::MessageReceived(BMessage *msg)
|
||||
release_sem(fCloseSem);
|
||||
}
|
||||
break;
|
||||
case 'page':
|
||||
|
||||
case kProgressMsg:
|
||||
fPage = "";
|
||||
if (fPass == 0)
|
||||
fPage << "Collecting Patterns Page: " << fPageCount;
|
||||
@@ -200,7 +173,13 @@ void StatusWindow::UpdateReport() {
|
||||
}
|
||||
}
|
||||
|
||||
void StatusWindow::WaitForClose() {
|
||||
void
|
||||
StatusWindow::NextPage() {
|
||||
PostMessage(kProgressMsg);
|
||||
}
|
||||
|
||||
void
|
||||
StatusWindow::WaitForClose() {
|
||||
fCloseSem = create_sem(0, "close_sem");
|
||||
|
||||
Lock();
|
||||
@@ -220,7 +199,7 @@ void StatusWindow::WaitForClose() {
|
||||
fCloseOption == kNoErrors && !hasErrors ||
|
||||
fCloseOption == kNoErrorsOrWarnings && !hasErrorsOrWarnings ||
|
||||
fCloseOption == kNoErrorsWarningsOrInfo && !hasErrorsWarningsOrInfo) {
|
||||
PostMessage('cncl');
|
||||
PostMessage(kCancelMsg);
|
||||
}
|
||||
Unlock();
|
||||
|
||||
|
||||
@@ -44,14 +44,11 @@ class StatusWindow : public HWindow
|
||||
private:
|
||||
int32 fPass;
|
||||
int32 fPages;
|
||||
// BString fCopy;
|
||||
|
||||
BString fPage;
|
||||
int32 fPageCount;
|
||||
// int fCopyCount;
|
||||
// BStringView *fCopyLabel;
|
||||
BStringView *fPageLabel;
|
||||
BStatusBar *fPageStatus;
|
||||
// BStatusBar *fCopyStatus;
|
||||
BButton *fCancel;
|
||||
PrinterDriver *fPrinterDriver;
|
||||
int32 fReportIndex;
|
||||
@@ -60,12 +57,14 @@ private:
|
||||
CloseOption fCloseOption;
|
||||
|
||||
void UpdateReport();
|
||||
|
||||
public:
|
||||
typedef HWindow inherited;
|
||||
|
||||
StatusWindow(int32 passes, int32 pages, PrinterDriver *pd);
|
||||
|
||||
void MessageReceived(BMessage *msg);
|
||||
void NextPage();
|
||||
void WaitForClose();
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
|
||||
PDF Writer printer driver.
|
||||
|
||||
Copyright (c) 2001-2003 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.
|
||||
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "Utils.h"
|
||||
|
||||
// --------------------------------------------------
|
||||
EscapeMessageFilter::EscapeMessageFilter(BWindow *window, int32 what)
|
||||
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, '_KYD')
|
||||
, fWindow(window),
|
||||
fWhat(what)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
filter_result
|
||||
EscapeMessageFilter::Filter(BMessage *msg, BHandler **target)
|
||||
{
|
||||
int32 key;
|
||||
// notify window with message fWhat if Escape key is hit
|
||||
if (B_OK == msg->FindInt32("key", &key) && key == 1) {
|
||||
fWindow->PostMessage(fWhat);
|
||||
return B_SKIP_MESSAGE;
|
||||
}
|
||||
return B_DISPATCH_MESSAGE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// copied from BeUtils.cpp
|
||||
static bool InList(const char* list[], const char* name) {
|
||||
for (int i = 0; list[i] != NULL; i ++) {
|
||||
if (strcmp(list[i], name) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// copied from BeUtils.cpp
|
||||
void AddFields(BMessage* to, const BMessage* from, bool overwrite, const char* excludeList[], const char* includeList[]) {
|
||||
if (to == from) return;
|
||||
char* name;
|
||||
type_code type;
|
||||
int32 count;
|
||||
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
||||
const void* data;
|
||||
ssize_t size;
|
||||
if (excludeList && InList(excludeList, name)) continue;
|
||||
if (includeList && !InList(includeList, name)) continue;
|
||||
|
||||
if (!overwrite && to->FindData(name, type, 0, &data, &size) == B_OK) {
|
||||
continue;
|
||||
}
|
||||
// replace existing data
|
||||
to->RemoveName(name);
|
||||
|
||||
for (int32 j = 0; j < count; j ++) {
|
||||
if (from->FindData(name, type, j, &data, &size) == B_OK) {
|
||||
// WTF why works AddData not for B_STRING_TYPE in R5.0.3?
|
||||
if (type == B_STRING_TYPE) {
|
||||
to->AddString(name, (const char*)data);
|
||||
} else if (type == B_MESSAGE_TYPE) {
|
||||
BMessage m;
|
||||
from->FindMessage(name, j, &m);
|
||||
to->AddMessage(name, &m);
|
||||
} else {
|
||||
to->AddData(name, type, data, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddString(BMessage* m, const char* name, const char* value) {
|
||||
if (m->HasString(name, 0)) {
|
||||
m->ReplaceString(name, value);
|
||||
} else {
|
||||
m->AddString(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers postscript ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
AddResources PS\ Compatible : PS.rsrc ;
|
||||
|
||||
@@ -12,7 +13,11 @@ Addon PS\ Compatible : Print :
|
||||
PSCap.cpp
|
||||
;
|
||||
|
||||
LinkAgainst PS\ Compatible : be libprint.a $(TARGET_LIBSTDC++) ;
|
||||
LinkAgainst PS\ Compatible :
|
||||
be
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
$(TARGET_LIBSTDC++) ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
PS\ Compatible :
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2001 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.
|
||||
|
||||
*/
|
||||
* Copyright 2001-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 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.
|
||||
|
||||
*/
|
||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include <AppKit.h>
|
||||
|
||||
|
||||
@@ -2,24 +2,27 @@ SubDir HAIKU_TOP src add-ons print drivers preview ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders interface print ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print ] ;
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
UsePrivateHeaders interface ;
|
||||
|
||||
AddResources Preview : Preview.rsrc ;
|
||||
|
||||
Addon Preview : Print :
|
||||
Utils.cpp
|
||||
InterfaceUtils.cpp
|
||||
MarginView.cpp
|
||||
PrinterSetupWindow.cpp
|
||||
PageSetupWindow.cpp
|
||||
JobSetupWindow.cpp
|
||||
Driver.cpp
|
||||
PrinterDriver.cpp
|
||||
Preview.cpp
|
||||
PrinterDriver.cpp
|
||||
PreviewDriver.cpp
|
||||
;
|
||||
|
||||
LinkAgainst Preview : be root libprint.a ;
|
||||
LinkAgainst Preview :
|
||||
be
|
||||
root
|
||||
libprintutils.a ;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
Preview :
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <SupportKit.h>
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#ifndef JOBSETUPWINDOW_H
|
||||
#define JOBSETUPWINDOW_H
|
||||
|
||||
@@ -1,709 +0,0 @@
|
||||
/*
|
||||
|
||||
MarginView.cpp
|
||||
|
||||
Copyright (c) 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.
|
||||
|
||||
Todo:
|
||||
|
||||
2 Make Strings constants or UI resources
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MARGIN_VIEW_H
|
||||
#include "MarginView.h"
|
||||
#endif
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <SupportKit.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*----------------- MarginView Private Constants --------------------*/
|
||||
|
||||
const int Y_OFFSET = 20;
|
||||
const int X_OFFSET = 10;
|
||||
const int STRING_SIZE = 50;
|
||||
const int _WIDTH = 50;
|
||||
const int NUM_COUNT = 10;
|
||||
|
||||
const static float _pointUnits = 1; // 1 point = 1 point
|
||||
const static float _inchUnits = 72; // 1" = 72 points
|
||||
const static float _cmUnits = 28.346; // 72/2.54 1cm = 28.346 points
|
||||
|
||||
const static float _minFieldWidth = 100; // pixels
|
||||
const static float _minUnitHeight = 30; // pixels
|
||||
const static float _drawInset = 10; // pixels
|
||||
|
||||
const static float unitFormat[] = { _inchUnits, _cmUnits, _pointUnits };
|
||||
const static char *unitNames[] = { "Inch", "cm", "Points", NULL };
|
||||
const static uint32 unitMsg[] = { MarginView::UNIT_INCH,
|
||||
MarginView::UNIT_CM,
|
||||
MarginView::UNIT_POINT };
|
||||
|
||||
const pattern dots = {{ 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }};
|
||||
|
||||
const rgb_color black = { 0,0,0,0 };
|
||||
const rgb_color red = { 255,0,0,0 };
|
||||
const rgb_color white = { 255,255,255,0 };
|
||||
const rgb_color gray = { 220,220,220,0 };
|
||||
|
||||
/*----------------- MarginView Public Methods --------------------*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param frame, BRect that is the size of the view passed to the superclase
|
||||
* @param pageWidth, float that is the points value of the page width
|
||||
* @param pageHeight, float that is the points value of the page height
|
||||
* @param margins, BRect values of margins
|
||||
* @param units, unit32 enum for units used in view
|
||||
* @return void
|
||||
*/
|
||||
MarginView::MarginView(BRect frame,
|
||||
int32 pageWidth,
|
||||
int32 pageHeight,
|
||||
BRect margins,
|
||||
uint32 units)
|
||||
|
||||
:BBox(frame, NULL, B_FOLLOW_ALL)
|
||||
{
|
||||
fUnits = units;
|
||||
fUnitValue = unitFormat[units];
|
||||
|
||||
SetLabel("Margins");
|
||||
|
||||
fMaxPageHeight = frame.Height() - _minUnitHeight - Y_OFFSET;
|
||||
fMaxPageWidth = frame.Width() - _minFieldWidth - X_OFFSET;
|
||||
|
||||
fMargins = margins;
|
||||
|
||||
fPageWidth = pageWidth;
|
||||
fPageHeight = pageHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
MarginView::~MarginView() {
|
||||
}
|
||||
|
||||
/*----------------- MarginView Public BeOS Hook Methods --------------------*/
|
||||
|
||||
/**
|
||||
* Draw
|
||||
*
|
||||
* @param BRect, the draw bounds
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::Draw(BRect rect)
|
||||
{
|
||||
BBox::Draw(rect);
|
||||
|
||||
float y_offset = (float)Y_OFFSET;
|
||||
float x_offset = (float)X_OFFSET;
|
||||
BRect r;
|
||||
|
||||
// Calculate offsets depending on orientation
|
||||
if (fPageWidth < fPageHeight) { // Portrait
|
||||
x_offset = (fMaxPageWidth/2 + X_OFFSET) - fViewWidth/2;
|
||||
} else { // landscape
|
||||
y_offset = (fMaxPageHeight/2 + Y_OFFSET) - fViewHeight/2;
|
||||
}
|
||||
|
||||
// draw the page
|
||||
SetHighColor(white);
|
||||
r = BRect(0, 0, fViewWidth, fViewHeight);
|
||||
r.OffsetBy(x_offset, y_offset);
|
||||
FillRect(r);
|
||||
SetHighColor(black);
|
||||
StrokeRect(r);
|
||||
|
||||
// draw margin
|
||||
SetHighColor(red);
|
||||
SetLowColor(white);
|
||||
r.top += fMargins.top;
|
||||
r.right -= fMargins.right;
|
||||
r.bottom -= fMargins.bottom;
|
||||
r.left += fMargins.left;
|
||||
StrokeRect(r, dots);
|
||||
|
||||
// draw the page size label
|
||||
SetHighColor(black);
|
||||
SetLowColor(gray);
|
||||
char str[STRING_SIZE];
|
||||
sprintf(str, "%2.1f x %2.1f", fPageWidth/fUnitValue, fPageHeight/fUnitValue);
|
||||
SetFontSize(10);
|
||||
DrawString((const char *)str, BPoint(x_offset, fMaxPageHeight + 40));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* BeOS Hook Function, change the size of the margin display
|
||||
*
|
||||
* @param width of the page
|
||||
* @param height the page
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::FrameResized(float width, float height)
|
||||
{
|
||||
fMaxPageHeight = height - _minUnitHeight - X_OFFSET;
|
||||
fMaxPageWidth = width - _minFieldWidth - Y_OFFSET;
|
||||
|
||||
CalculateViewSize(MARGIN_CHANGED);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* AttachToWindow
|
||||
*
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::AttachedToWindow()
|
||||
{
|
||||
if (Parent()) {
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
}
|
||||
ConstructGUI();
|
||||
}
|
||||
|
||||
/*----------------- MarginView Public Methods --------------------*/
|
||||
|
||||
/**
|
||||
* GetUnits
|
||||
*
|
||||
* @param none
|
||||
* @return uint32 enum, units in inches, cm, points
|
||||
*/
|
||||
uint32 MarginView::GetUnits(void) {
|
||||
return fUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateView, recalculate and redraw the view
|
||||
*
|
||||
* @param msg is a message to the calculate size to tell which field caused
|
||||
* the update to occur, or it is a general update.
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::UpdateView(uint32 msg)
|
||||
{
|
||||
Window()->Lock();
|
||||
CalculateViewSize(msg); // nur Preview in Margins BBox!
|
||||
Invalidate();
|
||||
Window()->Unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* SetPageSize
|
||||
*
|
||||
* @param pageWidth, float that is the unit value of the page width
|
||||
* @param pageHeight, float that is the unit value of the page height
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::SetPageSize(float pageWidth, float pageHeight)
|
||||
{
|
||||
fPageWidth = pageWidth;
|
||||
fPageHeight = pageHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetPageSize
|
||||
*
|
||||
* @param none
|
||||
* @return BPoint, contains actual point values of page in x, y of point
|
||||
*/
|
||||
BPoint MarginView::GetPageSize(void) {
|
||||
return BPoint(fPageWidth, fPageHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetMargin
|
||||
*
|
||||
* @param none
|
||||
* @return rect, return margin values always in points
|
||||
*/
|
||||
BRect MarginView::GetMargin(void)
|
||||
{
|
||||
BRect margin;
|
||||
|
||||
// convert the field text to values
|
||||
float ftop = atof(fTop->Text());
|
||||
float fright = atof(fRight->Text());
|
||||
float fleft = atof(fLeft->Text());
|
||||
float fbottom = atof(fBottom->Text());
|
||||
|
||||
// convert to units to points
|
||||
switch (fUnits)
|
||||
{
|
||||
case UNIT_INCH:
|
||||
// convert to points
|
||||
ftop *= _inchUnits;
|
||||
fright *= _inchUnits;
|
||||
fleft *= _inchUnits;
|
||||
fbottom *= _inchUnits;
|
||||
break;
|
||||
case UNIT_CM:
|
||||
// convert to points
|
||||
ftop *= _cmUnits;
|
||||
fright *= _cmUnits;
|
||||
fleft *= _cmUnits;
|
||||
fbottom *= _cmUnits;
|
||||
break;
|
||||
}
|
||||
|
||||
margin.Set(fleft, ftop, fright, fbottom);
|
||||
|
||||
return margin;
|
||||
}
|
||||
|
||||
/**
|
||||
* MesssageReceived()
|
||||
*
|
||||
* Receive messages for the view
|
||||
*
|
||||
* @param BMessage* , the message being received
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what)
|
||||
{
|
||||
case CHANGE_PAGE_SIZE: {
|
||||
float w;
|
||||
float h;
|
||||
msg->FindFloat("width", &w);
|
||||
msg->FindFloat("height", &h);
|
||||
SetPageSize(w, h);
|
||||
UpdateView(MARGIN_CHANGED);
|
||||
}
|
||||
break;
|
||||
|
||||
case FLIP_PAGE: {
|
||||
BPoint p;
|
||||
p = GetPageSize();
|
||||
SetPageSize(p.y, p.x);
|
||||
UpdateView(MARGIN_CHANGED);
|
||||
}
|
||||
break;
|
||||
|
||||
case MARGIN_CHANGED:
|
||||
UpdateView(MARGIN_CHANGED);
|
||||
break;
|
||||
|
||||
case TOP_MARGIN_CHANGED:
|
||||
UpdateView(TOP_MARGIN_CHANGED);
|
||||
break;
|
||||
|
||||
case LEFT_MARGIN_CHANGED:
|
||||
UpdateView(LEFT_MARGIN_CHANGED);
|
||||
break;
|
||||
|
||||
case RIGHT_MARGIN_CHANGED:
|
||||
UpdateView(RIGHT_MARGIN_CHANGED);
|
||||
break;
|
||||
|
||||
case BOTTOM_MARGIN_CHANGED:
|
||||
UpdateView(BOTTOM_MARGIN_CHANGED);
|
||||
break;
|
||||
|
||||
case UNIT_INCH:
|
||||
case UNIT_CM:
|
||||
case UNIT_POINT:
|
||||
SetUnits(msg->what);
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*----------------- MarginView Private Methods --------------------*/
|
||||
|
||||
/**
|
||||
* ConstructGUI()
|
||||
*
|
||||
* Creates the GUI for the View. MUST be called AFTER the View is attached to
|
||||
* the Window, or will crash and/or create strange behaviour
|
||||
*
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::ConstructGUI()
|
||||
{
|
||||
BMessage *msg;
|
||||
BString str;
|
||||
BMenuItem *item;
|
||||
BMenuField *mf;
|
||||
BPopUpMenu *menu;
|
||||
|
||||
// Create text fields
|
||||
msg = new BMessage(MARGIN_CHANGED);
|
||||
BRect r(Frame().Width() - be_plain_font->StringWidth("Top#") - _WIDTH,
|
||||
Y_OFFSET, Frame().Width() - X_OFFSET, _WIDTH);
|
||||
|
||||
// top
|
||||
str << fMargins.top/fUnitValue;
|
||||
fTop = new BTextControl( r, "top", "Top", str.String(), NULL,
|
||||
B_FOLLOW_RIGHT);
|
||||
|
||||
fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
|
||||
fTop->SetDivider(be_plain_font->StringWidth("Top#"));
|
||||
fTop->SetTarget(this);
|
||||
AllowOnlyNumbers(fTop, NUM_COUNT);
|
||||
AddChild(fTop);
|
||||
|
||||
|
||||
|
||||
|
||||
//left
|
||||
r.OffsetBy(0, Y_OFFSET);
|
||||
r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - _WIDTH;
|
||||
str = "";
|
||||
str << fMargins.left/fUnitValue;
|
||||
fLeft = new BTextControl( r, "left", "Left", str.String(), NULL,
|
||||
B_FOLLOW_RIGHT);
|
||||
|
||||
fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
|
||||
fLeft->SetDivider(be_plain_font->StringWidth("Left#"));
|
||||
fLeft->SetTarget(this);
|
||||
AllowOnlyNumbers(fLeft, NUM_COUNT);
|
||||
AddChild(fLeft);
|
||||
|
||||
|
||||
|
||||
|
||||
//bottom
|
||||
r.OffsetBy(0, Y_OFFSET);
|
||||
r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - _WIDTH;
|
||||
str = "";
|
||||
str << fMargins.bottom/fUnitValue;
|
||||
fBottom = new BTextControl( r, "bottom", "Bottom", str.String(), NULL,
|
||||
B_FOLLOW_RIGHT);
|
||||
|
||||
fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
|
||||
fBottom->SetDivider(be_plain_font->StringWidth("Bottom#"));
|
||||
fBottom->SetTarget(this);
|
||||
|
||||
AllowOnlyNumbers(fBottom, NUM_COUNT);
|
||||
AddChild(fBottom);
|
||||
|
||||
|
||||
|
||||
|
||||
//right
|
||||
r.OffsetBy(0, Y_OFFSET);
|
||||
r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - _WIDTH;
|
||||
str = "";
|
||||
str << fMargins.right/fUnitValue;
|
||||
fRight = new BTextControl( r, "right", "Right", str.String(), NULL,
|
||||
B_FOLLOW_RIGHT);
|
||||
|
||||
fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
|
||||
fRight->SetDivider(be_plain_font->StringWidth("Right#"));
|
||||
fRight->SetTarget(this);
|
||||
AllowOnlyNumbers(fRight, NUM_COUNT);
|
||||
AddChild(fRight);
|
||||
|
||||
|
||||
|
||||
// Create Units popup
|
||||
r.OffsetBy(-X_OFFSET,Y_OFFSET);
|
||||
r.right += Y_OFFSET;
|
||||
|
||||
menu = new BPopUpMenu("units");
|
||||
mf = new BMenuField(r, "units", "Units", menu,
|
||||
B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT|B_WILL_DRAW);
|
||||
mf->ResizeToPreferred();
|
||||
mf->SetDivider(be_plain_font->StringWidth("Units#"));
|
||||
|
||||
// Construct menu items
|
||||
for (int i=0; unitNames[i] != NULL; i++ )
|
||||
{
|
||||
msg = new BMessage(unitMsg[i]);
|
||||
menu->AddItem(item = new BMenuItem(unitNames[i], msg));
|
||||
item->SetTarget(this);
|
||||
if (fUnits == unitMsg[i]) {
|
||||
item->SetMarked(true);
|
||||
}
|
||||
}
|
||||
AddChild(mf);
|
||||
|
||||
// calculate the sizes for drawing page view
|
||||
CalculateViewSize(MARGIN_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AllowOnlyNumbers()
|
||||
*
|
||||
* @param BTextControl, the control we want to only allow numbers
|
||||
* @param maxNum, the maximun number of characters allowed
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::AllowOnlyNumbers(BTextControl *textControl, int maxNum)
|
||||
{
|
||||
BTextView *tv = textControl->TextView();
|
||||
|
||||
for (long i = 0; i < 256; i++) {
|
||||
tv->DisallowChar(i);
|
||||
}
|
||||
for (long i = '0'; i <= '9'; i++) {
|
||||
tv->AllowChar(i);
|
||||
}
|
||||
tv->AllowChar(B_BACKSPACE);
|
||||
tv->AllowChar('.');
|
||||
tv->SetMaxBytes(maxNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetMargin
|
||||
*
|
||||
* @param brect, margin values in rect
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::SetMargin(BRect margin) {
|
||||
fMargins = margin;
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUnits, called by the MarginMgr when the units popup is selected
|
||||
*
|
||||
* @param uint32, the enum that identifies the units requested to change to.
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::SetUnits(uint32 unit)
|
||||
{
|
||||
// do nothing if the current units are the same as requested
|
||||
if (unit == fUnits) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set the units Format
|
||||
fUnitValue = unitFormat[unit];
|
||||
|
||||
// convert the field text to values
|
||||
float ftop = atof(fTop->Text());
|
||||
float fright = atof(fRight->Text());
|
||||
float fleft = atof(fLeft->Text());
|
||||
float fbottom = atof(fBottom->Text());
|
||||
|
||||
// convert to target units
|
||||
switch (fUnits)
|
||||
{
|
||||
case UNIT_INCH:
|
||||
// convert to points
|
||||
ftop *= _inchUnits;
|
||||
fright *= _inchUnits;
|
||||
fleft *= _inchUnits;
|
||||
fbottom *= _inchUnits;
|
||||
// check for target unit is cm
|
||||
if (unit == UNIT_CM) {
|
||||
ftop /= _cmUnits;
|
||||
fright /= _cmUnits;
|
||||
fleft /= _cmUnits;
|
||||
fbottom /= _cmUnits;
|
||||
}
|
||||
break;
|
||||
case UNIT_CM:
|
||||
// convert to points
|
||||
ftop *= _cmUnits;
|
||||
fright *= _cmUnits;
|
||||
fleft *= _cmUnits;
|
||||
fbottom *= _cmUnits;
|
||||
// check for target unit is inches
|
||||
if (unit == UNIT_INCH) {
|
||||
ftop /= _inchUnits;
|
||||
fright /= _inchUnits;
|
||||
fleft /= _inchUnits;
|
||||
fbottom /= _inchUnits;
|
||||
}
|
||||
break;
|
||||
case UNIT_POINT:
|
||||
// check for target unit is cm
|
||||
if (unit == UNIT_CM) {
|
||||
ftop /= _cmUnits;
|
||||
fright /= _cmUnits;
|
||||
fleft /= _cmUnits;
|
||||
fbottom /= _cmUnits;
|
||||
}
|
||||
// check for target unit is inches
|
||||
if (unit == UNIT_INCH) {
|
||||
ftop /= _inchUnits;
|
||||
fright /= _inchUnits;
|
||||
fleft /= _inchUnits;
|
||||
fbottom /= _inchUnits;
|
||||
}
|
||||
break;
|
||||
}
|
||||
fUnits = unit;
|
||||
|
||||
// lock Window since these changes are from another thread
|
||||
Window()->Lock();
|
||||
|
||||
// set the fields to new units
|
||||
BString str;
|
||||
str << ftop;
|
||||
fTop->SetText(str.String());
|
||||
|
||||
str = "";
|
||||
str << fleft;
|
||||
fLeft->SetText(str.String());
|
||||
|
||||
str = "";
|
||||
str << fright;
|
||||
fRight->SetText(str.String());
|
||||
|
||||
str = "";
|
||||
str << fbottom;
|
||||
fBottom->SetText(str.String());
|
||||
|
||||
// update UI
|
||||
CalculateViewSize(MARGIN_CHANGED);
|
||||
Invalidate();
|
||||
|
||||
Window()->Unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* CalculateViewSize
|
||||
*
|
||||
* calculate the size of the view that is used
|
||||
* to show the page inside the margin box. This is dependent
|
||||
* on the size of the box and the room we have to show it and
|
||||
* the units that we are using and the orientation of the page.
|
||||
*
|
||||
* @param msg, the message for which field changed to check value bounds
|
||||
* @return void
|
||||
*/
|
||||
void MarginView::CalculateViewSize(uint32 msg)
|
||||
{
|
||||
// determine page orientation
|
||||
if (fPageHeight < fPageWidth) { // LANDSCAPE
|
||||
fViewWidth = fMaxPageWidth;
|
||||
fViewHeight = fPageHeight * (fViewWidth/fPageWidth);
|
||||
float hdiff = fViewHeight - fMaxPageHeight;
|
||||
if (hdiff > 0) {
|
||||
fViewHeight -= hdiff;
|
||||
fViewWidth -= hdiff;
|
||||
}
|
||||
} else { // PORTRAIT
|
||||
fViewHeight = fMaxPageHeight;
|
||||
fViewWidth = fPageWidth * (fViewHeight/fPageHeight);
|
||||
float wdiff = fViewWidth - fMaxPageWidth;
|
||||
if (wdiff > 0) {
|
||||
fViewHeight -= wdiff;
|
||||
fViewWidth -= wdiff;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate margins based on view size
|
||||
|
||||
// find the length of 1 pixel in points
|
||||
// ex: 80px/800pt = 0.1px/pt
|
||||
float pixelLength = fViewHeight/fPageHeight;
|
||||
|
||||
// convert the margins to points
|
||||
// The text field will have a number that us in the current unit
|
||||
// ex 0.2" * 72pt = 14.4pts
|
||||
float ftop = atof(fTop->Text()) * fUnitValue;
|
||||
float fright = atof(fRight->Text()) * fUnitValue;
|
||||
float fbottom = atof(fBottom->Text()) * fUnitValue;
|
||||
float fleft = atof(fLeft->Text()) * fUnitValue;
|
||||
|
||||
// Check that the margins don't overlap each other...
|
||||
float ph = fPageHeight;
|
||||
float pw = fPageWidth;
|
||||
BString str;
|
||||
|
||||
// Bounds calculation rules:
|
||||
if (msg == TOP_MARGIN_CHANGED)
|
||||
{
|
||||
// top must be <= bottom
|
||||
if (ftop > (ph - fbottom)) {
|
||||
ftop = ph - fbottom;
|
||||
str = "";
|
||||
str << ftop / fUnitValue;
|
||||
Window()->Lock();
|
||||
fTop->SetText(str.String());
|
||||
Window()->Unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg == BOTTOM_MARGIN_CHANGED)
|
||||
{
|
||||
// bottom must be <= pageHeight
|
||||
if (fbottom > (ph - ftop)) {
|
||||
fbottom = ph - ftop;
|
||||
str = "";
|
||||
str << fbottom / fUnitValue;
|
||||
Window()->Lock();
|
||||
fBottom->SetText(str.String());
|
||||
Window()->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == LEFT_MARGIN_CHANGED)
|
||||
{
|
||||
// left must be <= right
|
||||
if (fleft > (pw - fright)) {
|
||||
fleft = pw - fright;
|
||||
str = "";
|
||||
str << fleft / fUnitValue;
|
||||
Window()->Lock();
|
||||
fLeft->SetText(str.String());
|
||||
Window()->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == RIGHT_MARGIN_CHANGED)
|
||||
{
|
||||
// right must be <= fPageWidth
|
||||
if (fright > (pw - fleft)) {
|
||||
fright = pw - fleft;
|
||||
str = "";
|
||||
str << fright / fUnitValue;
|
||||
Window()->Lock();
|
||||
fRight->SetText(str.String());
|
||||
Window()->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// convert the unit value to pixels
|
||||
// ex: 14.4pt * 0.1px/pt = 1.44px
|
||||
fMargins.top = ftop * pixelLength;
|
||||
fMargins.right = fright * pixelLength;
|
||||
fMargins.bottom = fbottom * pixelLength;
|
||||
fMargins.left = fleft * pixelLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
|
||||
MarginView.h
|
||||
|
||||
Copyright (c) 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.
|
||||
|
||||
Documentation:
|
||||
|
||||
The MarginView is designed to be a self contained component that manages
|
||||
the display of a BBox control that shows a graphic of a page and its'
|
||||
margings. The component also includes text fields that are used to mofify
|
||||
the margin values and a popup to change the units used for the margins.
|
||||
|
||||
There are two interfaces for the MarginView component:
|
||||
|
||||
1) Set methods:
|
||||
- page size
|
||||
- orientation
|
||||
|
||||
Get methods to retrieve:
|
||||
- margins
|
||||
- page size
|
||||
|
||||
The method interface is available for the parent Component to call on
|
||||
the MarginView in response to the Window receiveing messages from
|
||||
other BControls that it contains, such as a Page Size popup. The
|
||||
Get methods are used to extract the page size and margins so that
|
||||
the printer driver may put these values into a BMessage for printing.
|
||||
|
||||
2) 'Optional' Message interface:
|
||||
- Set Page Size
|
||||
- Flip Orientation
|
||||
|
||||
The message interface is available for GUI Controls, BPopupMenu to send
|
||||
messages to the MarginView if the parent Window is not used to handle
|
||||
the messages.
|
||||
|
||||
General Use of MarginView component:
|
||||
|
||||
1) Simply construct a new MarginView object with the margins
|
||||
you want as defaults and add this view to the parent view
|
||||
of the dialog.
|
||||
|
||||
MarginView *mv;
|
||||
mv = new MarginView(viewSizeRect, pageWidth, pageHeight);
|
||||
parentView->AddChild(mv);
|
||||
|
||||
* you can also set the margins in the constructor, and the units:
|
||||
|
||||
mv = new MarginView(viewSizeRect, pageWidth, pageHeight
|
||||
marginRect, UNIT_POINTS);
|
||||
|
||||
! but remeber to have the marginRect values match the UNITS :-)
|
||||
|
||||
2) Set Page Size with methods:
|
||||
|
||||
mv-SetPageSize( pageWidth, pageHeight );
|
||||
mv->UpdateView();
|
||||
|
||||
3) Set Page Size with BMessage:
|
||||
|
||||
BMessage* msg = new BMessage(CHANGE_PAGE_SIZE);
|
||||
msg->AddFloat("width", pageWidth);
|
||||
msg->AddFloat("height", pageHeight);
|
||||
mv->PostMessage(msg);
|
||||
|
||||
4) Flip Page with methods:
|
||||
|
||||
mv-SetPageSize( pageHeight, pageWidth );
|
||||
mv->UpdateView();
|
||||
|
||||
5) Flip Page with BMessage:
|
||||
|
||||
BMessage* msg = new BMessage(FLIP_PAGE);
|
||||
mv->Looper()->PostMessage(msg);
|
||||
|
||||
Note: the MarginView DOES NOT keep track of the orientation. This
|
||||
should be done by the code for the Page setup dialog.
|
||||
|
||||
6) Get Page Size
|
||||
|
||||
BPoint pageSize = mv->GetPageSize();
|
||||
|
||||
7) Get Margins
|
||||
|
||||
BRect margins = mv->GetMargins();
|
||||
|
||||
8) Get Units
|
||||
|
||||
uint32 units = mv->GetUnits();
|
||||
|
||||
where units is one of:
|
||||
UNIT_INCH, 72 points/in
|
||||
UNIT_CM, 28.346 points/cm
|
||||
UNIT_POINT, 1 point/point
|
||||
*/
|
||||
|
||||
#ifndef MARGIN_VIEW_H
|
||||
#define MARGIN_VIEW_H
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <Looper.h>
|
||||
|
||||
class MarginManager;
|
||||
|
||||
// Messages that the MarginManager accepts
|
||||
const uint32 TOP_MARGIN_CHANGED = 'tchg';
|
||||
const uint32 RIGHT_MARGIN_CHANGED = 'rchg';
|
||||
const uint32 LEFT_MARGIN_CHANGED = 'lchg';
|
||||
const uint32 BOTTOM_MARGIN_CHANGED = 'bchg';
|
||||
const uint32 MARGIN_CHANGED = 'mchg';
|
||||
const uint32 CHANGE_PAGE_SIZE = 'chps';
|
||||
const uint32 FLIP_PAGE = 'flip';
|
||||
|
||||
/**
|
||||
* Class MarginView
|
||||
*/
|
||||
class MarginView : public BBox
|
||||
{
|
||||
friend class MarginManager;
|
||||
|
||||
public:
|
||||
// used to index unitFormat array
|
||||
typedef enum {
|
||||
UNIT_INCH = 0,
|
||||
UNIT_CM,
|
||||
UNIT_POINT
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// GUI components
|
||||
BTextControl *fTop, *fBottom, *fLeft, *fRight;
|
||||
|
||||
// rect that holds the margins for the page as a set of point offsets
|
||||
BRect fMargins;
|
||||
|
||||
// the maximum size of the page view calculated from the view size
|
||||
float fMaxPageWidth;
|
||||
float fMaxPageHeight;
|
||||
|
||||
// the actual size of the page in points
|
||||
float fPageHeight;
|
||||
float fPageWidth;
|
||||
|
||||
// the units used to calculate the page size
|
||||
uint32 fUnits;
|
||||
float fUnitValue;
|
||||
|
||||
// the size of the drawing area we have to draw the view in pixels
|
||||
float fViewHeight;
|
||||
float fViewWidth;
|
||||
|
||||
// Calculate the view size for the margins
|
||||
void CalculateViewSize(uint32 msg);
|
||||
|
||||
// performed internally using the supplied popup
|
||||
void SetUnits(uint32 unit);
|
||||
|
||||
// performed internally using text fields
|
||||
void SetMargin(BRect margin);
|
||||
|
||||
// utility method
|
||||
void AllowOnlyNumbers(BTextControl *textControl, int maxNum);
|
||||
|
||||
public:
|
||||
MarginView(BRect rect,
|
||||
int32 pageWidth = 0,
|
||||
int32 pageHeight = 0,
|
||||
BRect margins = BRect(1, 1, 1, 1), // default to 1 inch
|
||||
uint32 units = UNIT_INCH);
|
||||
|
||||
~MarginView();
|
||||
|
||||
/// all the GUI construction code
|
||||
void ConstructGUI();
|
||||
|
||||
// page size
|
||||
void SetPageSize(float pageWidth, float pageHeight);
|
||||
// point.x = width, point.y = height
|
||||
BPoint GetPageSize(void);
|
||||
|
||||
// margin
|
||||
BRect GetMargin(void);
|
||||
|
||||
// orientation
|
||||
// None, this state should be saved elsewhere in the page setup code
|
||||
// and not here. See the FLIP_PAGE message to perform this function.
|
||||
|
||||
// units
|
||||
uint32 GetUnits(void);
|
||||
|
||||
// will cause a recalc and redraw
|
||||
void UpdateView(uint32 msg);
|
||||
|
||||
// BeOS Hook methods
|
||||
virtual void AttachedToWindow(void);
|
||||
void Draw(BRect rect);
|
||||
void FrameResized(float width, float height);
|
||||
void MessageReceived(BMessage *msg);
|
||||
};
|
||||
|
||||
#endif //MARGIN_VIEW_H
|
||||
@@ -1,35 +1,13 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 OpenBeOS.
|
||||
Copyright (c) 2005 Haiku.
|
||||
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
Simon Gauvin
|
||||
Michael Pfeiffer
|
||||
Hartmut Reh
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
* Hartmut Reh
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -38,9 +16,9 @@ THE SOFTWARE.
|
||||
#include "PrinterDriver.h"
|
||||
#include "PageSetupWindow.h"
|
||||
|
||||
#include "BeUtils.h"
|
||||
#include "MarginView.h"
|
||||
|
||||
|
||||
// static global variables
|
||||
static struct
|
||||
{
|
||||
@@ -113,7 +91,7 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
|
||||
int32 orient;
|
||||
BRect page;
|
||||
BRect margin(0, 0, 0, 0);
|
||||
int32 units = MarginView::UNIT_INCH;
|
||||
MarginUnit units = kUnitInch;
|
||||
BString setting_value;
|
||||
|
||||
// load orientation
|
||||
@@ -131,7 +109,10 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
|
||||
}
|
||||
|
||||
// Load units
|
||||
fSetupMsg->FindInt32("units", &units);
|
||||
int32 unitsValue;
|
||||
if (fSetupMsg->FindInt32("units", &unitsValue) == B_OK) {
|
||||
units = (MarginUnit)unitsValue;
|
||||
}
|
||||
|
||||
// add a *dialog* background
|
||||
r = Bounds();
|
||||
@@ -149,7 +130,7 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
|
||||
margin.right = page.right - margin.right;
|
||||
margin.bottom = page.bottom - margin.bottom;
|
||||
} else {
|
||||
margin.Set(0, 0, 0, 0);
|
||||
margin.Set(28.34, 28.34, 28.34, 28.34); // 28.34 dots = 1cm
|
||||
}
|
||||
|
||||
fMarginView = new MarginView(BRect(20,20,200,160), (int32)width, (int32)height,
|
||||
@@ -340,7 +321,7 @@ PageSetupWindow::UpdateSetupMessage()
|
||||
SetRect(fSetupMsg, "printable_rect", ScaleRect(margin, scaleR));
|
||||
|
||||
// save the units used
|
||||
int32 units = fMarginView->GetUnits();
|
||||
int32 units = fMarginView->GetMarginUnit();
|
||||
SetInt32(fSetupMsg, "units", units);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,13 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 OpenBeOS.
|
||||
Copyright (c) 2005 Haiku.
|
||||
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
Simon Gauvin
|
||||
Michael Pfeiffer
|
||||
Hartmut Reh
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
* Hartmut Reh
|
||||
*/
|
||||
|
||||
#ifndef PAGESETUPWINDOW_H
|
||||
#define PAGESETUPWINDOW_H
|
||||
|
||||
@@ -1,38 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
* Hartmut Reh
|
||||
*/
|
||||
|
||||
Preview
|
||||
|
||||
Copyright (c) 2002, 2003 OpenBeOS.
|
||||
Copyright (c) 2005 Haiku.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
Hartmut Reh
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
// TODO Remove. Use shared/libprint/Preview.cpp instead.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Debug.h>
|
||||
#include <String.h>
|
||||
#include "BeUtils.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include "Preview.h"
|
||||
|
||||
@@ -1,33 +1,11 @@
|
||||
/*
|
||||
|
||||
Preview
|
||||
|
||||
Copyright (c) 2002, 2003 OpenBeOS.
|
||||
Copyright (c) 2005 Haiku.
|
||||
|
||||
Author:
|
||||
Michael Pfeiffer
|
||||
Hartmut Reh
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
* Hartmut Reh
|
||||
*/
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include "PrintJobReader.h"
|
||||
|
||||
@@ -1,31 +1,10 @@
|
||||
/*
|
||||
|
||||
PreviewDriver
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include "PreviewDriver.h"
|
||||
|
||||
@@ -43,8 +22,8 @@ PrinterDriver* instanciate_driver(BNode *spoolDir)
|
||||
// About dialog text:
|
||||
const char*
|
||||
kAbout =
|
||||
"Preview for BeOS\n"
|
||||
"© 2003 OpenBeOS\n"
|
||||
"Preview for Haiku\n"
|
||||
"© 2003-2007 Haiku\n"
|
||||
"by Michael Pfeiffer\n"
|
||||
"\n"
|
||||
"Based on PDF Writer by\nPhilippe Houdoin, Simon Gauvin, Michael Pfeiffer\n"
|
||||
|
||||
@@ -1,31 +1,10 @@
|
||||
/*
|
||||
|
||||
Preview
|
||||
|
||||
Copyright (c) 2002, 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include "Preview.h"
|
||||
#include "PrinterDriver.h"
|
||||
|
||||
@@ -1,34 +1,13 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
* Dr. Hartmut Reh
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h> // for memset()
|
||||
@@ -105,13 +84,6 @@ PrinterDriver::PrintJob
|
||||
if (!fJobFile || !fPrinterNode)
|
||||
return B_ERROR;
|
||||
|
||||
if (fPrintTransport.Open(fPrinterNode) != B_OK) {
|
||||
return B_ERROR;
|
||||
}
|
||||
if (fPrintTransport.IsPrintToFileCanceled()) {
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// read print file header
|
||||
fJobFile->Seek(0, SEEK_SET);
|
||||
fJobFile->Read(&pfh, sizeof(pfh));
|
||||
|
||||
@@ -1,40 +1,19 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2001 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.
|
||||
|
||||
*/
|
||||
* Copyright 2001-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
* Dr. Hartmut Reh
|
||||
*/
|
||||
|
||||
#ifndef PRINTERDRIVER_H
|
||||
#define PRINTERDRIVER_H
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include "PrintTransport.h"
|
||||
#include "InterfaceUtils.h"
|
||||
|
||||
#ifndef ROUND_UP
|
||||
@@ -102,7 +81,6 @@ public:
|
||||
inline BFile *JobFile() { return fJobFile; }
|
||||
inline BNode *PrinterNode() { return fPrinterNode; }
|
||||
inline BMessage *JobMsg() { return fJobMsg; }
|
||||
inline BDataIO *Transport() { return fPrintTransport.GetDataIO(); }
|
||||
inline int32 Pass() const { return fPass; }
|
||||
|
||||
// publics status code
|
||||
@@ -123,9 +101,6 @@ private:
|
||||
|
||||
bool fPrinting;
|
||||
int32 fPass;
|
||||
|
||||
// transport-related
|
||||
PrintTransport fPrintTransport;
|
||||
};
|
||||
|
||||
#endif // #ifndef PRINTERDRIVER_H
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <StorageKit.h>
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
/*
|
||||
|
||||
Preview printer driver.
|
||||
|
||||
Copyright (c) 2003 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.
|
||||
|
||||
*/
|
||||
* Copyright 2003-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin
|
||||
* Simon Gauvin
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#ifndef PRINTERSETUPWINDOW_H
|
||||
#define PRINTERSETUPWINDOW_H
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
SubDir HAIKU_TOP src add-ons print drivers shared ;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons print drivers shared utils ;
|
||||
SubInclude HAIKU_TOP src add-ons print drivers shared libprint ;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Region.h>
|
||||
#include <TextControl.h>
|
||||
#include <TextControl.h>
|
||||
#include <StopWatch.h>
|
||||
#include <View.h>
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
@@ -34,12 +35,17 @@ using namespace std;
|
||||
#define std
|
||||
#endif
|
||||
|
||||
// Measure printJob() time. Either true or false.
|
||||
#define MEASURE_PRINT_JOB_TIME false
|
||||
|
||||
enum {
|
||||
kMaxMemorySize = (4 *1024 *1024)
|
||||
};
|
||||
|
||||
GraphicsDriver::GraphicsDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
|
||||
: fMsg(msg), fPrinterData(printer_data), fPrinterCap(printer_cap)
|
||||
: fMsg(msg)
|
||||
, fPrinterData(printer_data)
|
||||
, fPrinterCap(printer_cap)
|
||||
{
|
||||
fView = NULL;
|
||||
fBitmap = NULL;
|
||||
@@ -60,9 +66,29 @@ static BRect RotateRect(BRect rect)
|
||||
return rotated;
|
||||
}
|
||||
|
||||
void
|
||||
GraphicsDriver::setupData(BFile *spool_file, long page_count)
|
||||
bool
|
||||
GraphicsDriver::setupData(BFile *spool_file)
|
||||
{
|
||||
if (fOrgJobData != NULL) {
|
||||
// already initialized
|
||||
return true;
|
||||
}
|
||||
|
||||
print_file_header pfh;
|
||||
|
||||
spool_file->Seek(0, SEEK_SET);
|
||||
spool_file->Read(&pfh, sizeof(pfh));
|
||||
|
||||
DBGMSG(("print_file_header::version = 0x%x\n", pfh.version));
|
||||
DBGMSG(("print_file_header::page_count = %d\n", pfh.page_count));
|
||||
DBGMSG(("print_file_header::first_page = 0x%x\n", (int)pfh.first_page));
|
||||
|
||||
if (pfh.page_count <= 0) {
|
||||
// nothing to print
|
||||
return false;
|
||||
}
|
||||
|
||||
fPageCount = (uint32) pfh.page_count;
|
||||
BMessage *msg = new BMessage();
|
||||
msg->Unflatten(spool_file);
|
||||
fOrgJobData = new JobData(msg, fPrinterCap, JobData::kJobSettings);
|
||||
@@ -87,7 +113,7 @@ GraphicsDriver::setupData(BFile *spool_file, long page_count)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fOrgJobData->getCollate() && page_count > 1) {
|
||||
if (fOrgJobData->getCollate() && fPageCount > 1) {
|
||||
fRealJobData->setCopies(1);
|
||||
fInternalCopies = fOrgJobData->getCopies();
|
||||
} else {
|
||||
@@ -95,6 +121,7 @@ GraphicsDriver::setupData(BFile *spool_file, long page_count)
|
||||
}
|
||||
|
||||
fSpoolMetaData = new SpoolMetaData(spool_file);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -159,8 +186,8 @@ GraphicsDriver::cleanupBitmap()
|
||||
fView = NULL;
|
||||
}
|
||||
|
||||
static
|
||||
BPoint get_scale(JobData *org_job_data)
|
||||
BPoint
|
||||
GraphicsDriver::getScale(int32 nup, BRect physicalRect, float scaling)
|
||||
{
|
||||
float width;
|
||||
float height;
|
||||
@@ -168,13 +195,13 @@ BPoint get_scale(JobData *org_job_data)
|
||||
|
||||
scale.x = scale.y = 1.0f;
|
||||
|
||||
switch (org_job_data->getNup()) {
|
||||
switch (nup) {
|
||||
case 1:
|
||||
scale.x = scale.y = 1.0f;
|
||||
break;
|
||||
case 2: /* 1x2 or 2x1 */
|
||||
width = org_job_data->getPhysicalRect().Width();
|
||||
height = org_job_data->getPhysicalRect().Height();
|
||||
width = physicalRect.Width();
|
||||
height = physicalRect.Height();
|
||||
if (width < height) { // portrait
|
||||
scale.x = height / 2.0f / width;
|
||||
scale.y = width / height;
|
||||
@@ -184,8 +211,8 @@ BPoint get_scale(JobData *org_job_data)
|
||||
}
|
||||
break;
|
||||
case 8: /* 2x4 or 4x2 */
|
||||
width = org_job_data->getPhysicalRect().Width();
|
||||
height = org_job_data->getPhysicalRect().Height();
|
||||
width = physicalRect.Width();
|
||||
height = physicalRect.Height();
|
||||
if (width < height) {
|
||||
scale.x = height / 4.0f / width;
|
||||
scale.y = width / height / 2.0f;
|
||||
@@ -195,8 +222,8 @@ BPoint get_scale(JobData *org_job_data)
|
||||
}
|
||||
break;
|
||||
case 32: /* 4x8 or 8x4 */
|
||||
width = org_job_data->getPhysicalRect().Width();
|
||||
height = org_job_data->getPhysicalRect().Height();
|
||||
width = physicalRect.Width();
|
||||
height = physicalRect.Height();
|
||||
if (width < height) {
|
||||
scale.x = height / 8.0f / width;
|
||||
scale.y = width / height / 4.0f;
|
||||
@@ -237,32 +264,30 @@ BPoint get_scale(JobData *org_job_data)
|
||||
break;
|
||||
}
|
||||
|
||||
scale.x = scale.x * org_job_data->getScaling() / 100.0;
|
||||
scale.y = scale.y * org_job_data->getScaling() / 100.0;
|
||||
scale.x = scale.x * scaling / 100.0;
|
||||
scale.y = scale.y * scaling / 100.0;
|
||||
|
||||
DBGMSG(("real scale = %f, %f\n", scale.x, scale.y));
|
||||
return scale;
|
||||
}
|
||||
|
||||
static BPoint
|
||||
get_offset(
|
||||
int index,
|
||||
const BPoint *scale,
|
||||
JobData *org_job_data)
|
||||
BPoint
|
||||
GraphicsDriver::getOffset(int32 nup, int index, JobData::Orientation orientation,
|
||||
const BPoint *scale, BRect scaledPhysicalRect, BRect scaledPrintableRect,
|
||||
BRect physicalRect)
|
||||
{
|
||||
BPoint offset;
|
||||
offset.x = 0;
|
||||
offset.y = 0;
|
||||
|
||||
float width = org_job_data->getScaledPhysicalRect().Width();
|
||||
float height = org_job_data->getScaledPhysicalRect().Height();
|
||||
float width = scaledPhysicalRect.Width();
|
||||
float height = scaledPhysicalRect.Height();
|
||||
|
||||
switch (org_job_data->getNup()) {
|
||||
switch (nup) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
if (index == 1) {
|
||||
if (JobData::kPortrait == org_job_data->getOrientation()) {
|
||||
if (JobData::kPortrait == orientation) {
|
||||
offset.x = width;
|
||||
} else {
|
||||
offset.y = height;
|
||||
@@ -270,7 +295,7 @@ get_offset(
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (JobData::kPortrait == org_job_data->getOrientation()) {
|
||||
if (JobData::kPortrait == orientation) {
|
||||
offset.x = width * (index / 2);
|
||||
offset.y = height * (index % 2);
|
||||
} else {
|
||||
@@ -279,7 +304,7 @@ get_offset(
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if (JobData::kPortrait == org_job_data->getOrientation()) {
|
||||
if (JobData::kPortrait == orientation) {
|
||||
offset.x = width * (index / 4);
|
||||
offset.y = height * (index % 4);
|
||||
} else {
|
||||
@@ -330,10 +355,8 @@ get_offset(
|
||||
}
|
||||
|
||||
// adjust margin
|
||||
offset.x += org_job_data->getScaledPrintableRect().left -
|
||||
org_job_data->getPhysicalRect().left;
|
||||
offset.y += org_job_data->getScaledPrintableRect().top -
|
||||
org_job_data->getPhysicalRect().top;
|
||||
offset.x += scaledPrintableRect.left - physicalRect.left;
|
||||
offset.y += scaledPrintableRect.top - physicalRect.top;
|
||||
|
||||
float real_scale = min(scale->x, scale->y);
|
||||
if (real_scale != scale->x)
|
||||
@@ -348,7 +371,6 @@ get_offset(
|
||||
bool
|
||||
GraphicsDriver::printPage(PageDataList *pages)
|
||||
{
|
||||
#ifndef USE_PREVIEW_FOR_DEBUG
|
||||
BPoint offset;
|
||||
offset.x = 0.0f;
|
||||
offset.y = 0.0f;
|
||||
@@ -364,8 +386,7 @@ GraphicsDriver::printPage(PageDataList *pages)
|
||||
fView->ConstrainClippingRegion(NULL);
|
||||
fView->FillRect(fView->Bounds());
|
||||
|
||||
|
||||
BPoint scale = get_scale(fOrgJobData);
|
||||
BPoint scale = getScale(fOrgJobData->getNup(), fOrgJobData->getPhysicalRect(), fOrgJobData->getScaling());
|
||||
float real_scale = min(scale.x, scale.y) * fOrgJobData->getXres() / 72.0f;
|
||||
fView->SetScale(real_scale);
|
||||
float x = offset.x / real_scale;
|
||||
@@ -373,7 +394,7 @@ GraphicsDriver::printPage(PageDataList *pages)
|
||||
int page_index = 0;
|
||||
|
||||
for (PageDataList::iterator it = pages->begin(); it != pages->end(); it++) {
|
||||
BPoint left_top(get_offset(page_index++, &scale, fOrgJobData));
|
||||
BPoint left_top(getOffset(fOrgJobData->getNup(), page_index++, fOrgJobData->getOrientation(), &scale, fOrgJobData->getScaledPhysicalRect(), fOrgJobData->getScaledPrintableRect(), fOrgJobData->getPhysicalRect()));
|
||||
left_top.x -= x;
|
||||
left_top.y -= y;
|
||||
BRect clip(fOrgJobData->getScaledPrintableRect());
|
||||
@@ -398,45 +419,6 @@ GraphicsDriver::printPage(PageDataList *pages)
|
||||
return false;
|
||||
}
|
||||
} while (offset.x >= 0.0f && offset.y >= 0.0f);
|
||||
#else // !USE_PREVIEW_FOR_DEBUG
|
||||
fView->SetScale(1.0);
|
||||
fView->SetHighColor(255, 255, 255);
|
||||
fView->ConstrainClippingRegion(NULL);
|
||||
fView->FillRect(fView->Bounds());
|
||||
|
||||
BPoint scale = get_scale(fOrgJobData);
|
||||
fView->SetScale(min(scale.x, scale.y));
|
||||
|
||||
int page_index = 0;
|
||||
PageDataList::iterator it;
|
||||
|
||||
for (it = pages->begin() ; it != pages->end() ; it++) {
|
||||
BPoint left_top(get_offset(page_index, &scale, fOrgJobData));
|
||||
BRect clip(fOrgJobData->getScaledPrintableRect());
|
||||
clip.OffsetTo(left_top);
|
||||
BRegion *region = new BRegion();
|
||||
region->Set(clip);
|
||||
fView->ConstrainClippingRegion(region);
|
||||
delete region;
|
||||
if ((*it)->startEnum()) {
|
||||
bool more;
|
||||
do {
|
||||
PictureData *picture_data;
|
||||
more = (*it)->enumObject(&picture_data);
|
||||
BPoint real_offset = left_top + picture_data->point;
|
||||
fView->DrawPicture(picture_data->picture, real_offset);
|
||||
fView->Sync();
|
||||
delete picture_data;
|
||||
} while (more);
|
||||
}
|
||||
page_index++;
|
||||
}
|
||||
|
||||
BRect rc(fRealJobData->getPhysicalRect());
|
||||
rc.OffsetTo(30.0, 30.0);
|
||||
PreviewWindow *preview = new PreviewWindow(rc, "Preview", fBitmap);
|
||||
preview->Go();
|
||||
#endif // USE_PREVIEW_FOR_DEBUG
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -484,6 +466,7 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
|
||||
// send the page multiple times to the printer
|
||||
copies = fRealJobData->getCopies();
|
||||
}
|
||||
fStatusWindow -> SetPageCopies(copies); // inform fStatusWindow about number of copies
|
||||
|
||||
// printing of even/odd numbered pages only is valid in simplex mode
|
||||
bool simplex = fRealJobData->getPrintStyle() == JobData::kSimplex;
|
||||
@@ -514,6 +497,11 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
|
||||
|
||||
// print each physical page "copies" of times
|
||||
for (copy = 0; success && copy < copies; copy ++) {
|
||||
|
||||
// Update the status / cancel job
|
||||
if (fStatusWindow->UpdateStatusBar(page_index, copy))
|
||||
return false;
|
||||
|
||||
success = startPage(page_index);
|
||||
if (!success)
|
||||
break;
|
||||
@@ -549,20 +537,19 @@ GraphicsDriver::printDocument(SpoolData *spool_data)
|
||||
return success;
|
||||
}
|
||||
|
||||
const JobData*
|
||||
GraphicsDriver::getJobData(BFile *spoolFile)
|
||||
{
|
||||
setupData(spoolFile);
|
||||
return fOrgJobData;
|
||||
}
|
||||
|
||||
bool
|
||||
GraphicsDriver::printJob(BFile *spool_file)
|
||||
{
|
||||
bool success = true;
|
||||
print_file_header pfh;
|
||||
|
||||
spool_file->Seek(0, SEEK_SET);
|
||||
spool_file->Read(&pfh, sizeof(pfh));
|
||||
|
||||
DBGMSG(("print_file_header::version = 0x%x\n", pfh.version));
|
||||
DBGMSG(("print_file_header::page_count = %d\n", pfh.page_count));
|
||||
DBGMSG(("print_file_header::first_page = 0x%x\n", (int)pfh.first_page));
|
||||
|
||||
if (pfh.page_count <= 0) {
|
||||
if (!setupData(spool_file)) {
|
||||
// silently exit if there is nothing to print
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -571,11 +558,18 @@ GraphicsDriver::printJob(BFile *spool_file)
|
||||
if (fTransport->check_abort()) {
|
||||
success = false;
|
||||
} else if (!fTransport->is_print_to_file_canceled()) {
|
||||
setupData(spool_file, pfh.page_count);
|
||||
BStopWatch stopWatch("printJob", !MEASURE_PRINT_JOB_TIME);
|
||||
setupBitmap();
|
||||
SpoolData spool_data(spool_file, pfh.page_count, fOrgJobData->getNup(), fOrgJobData->getReverse());
|
||||
SpoolData spool_data(spool_file, fPageCount, fOrgJobData->getNup(), fOrgJobData->getReverse());
|
||||
success = startDoc();
|
||||
if (success) {
|
||||
fStatusWindow = new StatusWindow(
|
||||
fRealJobData->getPageSelection() == JobData::kOddNumberedPages,
|
||||
fRealJobData->getPageSelection() == JobData::kEvenNumberedPages,
|
||||
fRealJobData->getFirstPage(),
|
||||
fPageCount,
|
||||
fInternalCopies,fRealJobData->getNup());
|
||||
|
||||
while (fInternalCopies--) {
|
||||
success = printDocument(&spool_data);
|
||||
if (success == false) {
|
||||
@@ -583,6 +577,8 @@ GraphicsDriver::printJob(BFile *spool_file)
|
||||
}
|
||||
}
|
||||
endDoc(success);
|
||||
|
||||
fStatusWindow -> Quit();
|
||||
}
|
||||
cleanupBitmap();
|
||||
cleanupData();
|
||||
|
||||
@@ -6,6 +6,8 @@ SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print libprint ] ;
|
||||
|
||||
# for BeUtils.h
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print ] ;
|
||||
# for Utils.h, InterfaceUtils.h
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
StaticLibrary libprint.a :
|
||||
AboutBox.cpp
|
||||
@@ -18,7 +20,6 @@ StaticLibrary libprint.a :
|
||||
JSDSlider.cpp
|
||||
JobData.cpp
|
||||
JobSetupDlg.cpp
|
||||
MarginView.cpp
|
||||
PackBits.cpp
|
||||
PageSetupDlg.cpp
|
||||
PagesView.cpp
|
||||
@@ -28,6 +29,7 @@ StaticLibrary libprint.a :
|
||||
PrinterCap.cpp
|
||||
PrintProcess.cpp
|
||||
SpoolMetaData.cpp
|
||||
StatusWindow.cpp
|
||||
Transport.cpp
|
||||
UIDriver.cpp
|
||||
ValidRect.cpp
|
||||
|
||||
@@ -19,6 +19,7 @@ static const char *kJDScaledPrintableRect = "printable_rect";
|
||||
static const char *kJDFirstPage = "first_page";
|
||||
static const char *kJDLastPage = "last_page";
|
||||
|
||||
static const char *kJDShowPreview = "JJJJ_showPreview";
|
||||
static const char *kJDPaper = "JJJJ_paper";
|
||||
static const char *kJDNup = "JJJJ_nup";
|
||||
static const char *kJDGamma = "JJJJ_gamma";
|
||||
@@ -49,6 +50,7 @@ JobData::~JobData()
|
||||
|
||||
JobData::JobData(const JobData &job_data)
|
||||
{
|
||||
fShowPreview = job_data.fShowPreview;
|
||||
fPaper = job_data.fPaper;
|
||||
fXRes = job_data.fXRes;
|
||||
fYRes = job_data.fYRes;
|
||||
@@ -82,6 +84,7 @@ JobData::JobData(const JobData &job_data)
|
||||
|
||||
JobData &JobData::operator = (const JobData &job_data)
|
||||
{
|
||||
fShowPreview = job_data.fShowPreview;
|
||||
fPaper = job_data.fPaper;
|
||||
fXRes = job_data.fXRes;
|
||||
fYRes = job_data.fYRes;
|
||||
@@ -121,6 +124,11 @@ void JobData::load(BMessage *msg, const PrinterCap *cap, Settings settings)
|
||||
|
||||
const PaperCap *paperCap = NULL;
|
||||
|
||||
if (msg->HasBool(kJDShowPreview))
|
||||
fShowPreview = msg->FindBool(kJDShowPreview);
|
||||
else
|
||||
fShowPreview = false;
|
||||
|
||||
if (msg->HasInt32(kJDPaper))
|
||||
fPaper = (Paper)msg->FindInt32(kJDPaper);
|
||||
else if (cap->isSupport(PrinterCap::kPaper)) {
|
||||
@@ -263,8 +271,10 @@ void JobData::load(BMessage *msg, const PrinterCap *cap, Settings settings)
|
||||
else
|
||||
fPageOrder = kAcrossFromLeft;
|
||||
|
||||
if (msg->HasBool(kJDColor))
|
||||
fColor = msg->FindBool(kJDColor) ? kColor : kMonochrome;
|
||||
if (msg->HasInt32(kJDColor))
|
||||
fColor = (Color)msg->FindInt32(kJDColor);
|
||||
else if (cap->isSupport(PrinterCap::kColor))
|
||||
fColor = ((const ColorCap *)cap->getDefaultCap(PrinterCap::kColor))->color;
|
||||
else
|
||||
fColor = kMonochrome;
|
||||
|
||||
@@ -291,142 +301,108 @@ void JobData::save(BMessage *msg)
|
||||
}
|
||||
|
||||
// page settings
|
||||
if (msg->HasInt32(kJDPaper))
|
||||
msg->ReplaceInt32(kJDPaper, fPaper);
|
||||
else
|
||||
msg->RemoveName(kJDPaper);
|
||||
msg->AddInt32(kJDPaper, fPaper);
|
||||
|
||||
if (msg->HasInt64(kJDXRes))
|
||||
msg->ReplaceInt64(kJDXRes, fXRes);
|
||||
else
|
||||
msg->RemoveName(kJDXRes);
|
||||
msg->AddInt64(kJDXRes, fXRes);
|
||||
|
||||
if (msg->HasInt64(kJDYRes))
|
||||
msg->ReplaceInt64(kJDYRes, fYRes);
|
||||
else
|
||||
msg->RemoveName(kJDYRes);
|
||||
msg->AddInt64(kJDYRes, fYRes);
|
||||
|
||||
if (msg->HasInt32(kJDOrientation))
|
||||
msg->ReplaceInt32(kJDOrientation, fOrientation);
|
||||
else
|
||||
msg->RemoveName(kJDOrientation);
|
||||
msg->AddInt32(kJDOrientation, fOrientation);
|
||||
|
||||
if (msg->HasFloat(kJDScaling))
|
||||
msg->ReplaceFloat(kJDScaling, fScaling);
|
||||
else
|
||||
msg->RemoveName(kJDScaling);
|
||||
msg->AddFloat(kJDScaling, fScaling);
|
||||
|
||||
if (msg->HasRect(kJDPaperRect))
|
||||
msg->ReplaceRect(kJDPaperRect, fPaperRect);
|
||||
else
|
||||
msg->RemoveName(kJDPaperRect);
|
||||
msg->AddRect(kJDPaperRect, fPaperRect);
|
||||
|
||||
if (msg->HasRect(kJDScaledPaperRect))
|
||||
msg->ReplaceRect(kJDScaledPaperRect, fScaledPaperRect);
|
||||
else
|
||||
msg->RemoveName(kJDScaledPaperRect);
|
||||
msg->AddRect(kJDScaledPaperRect, fScaledPaperRect);
|
||||
|
||||
if (msg->HasRect(kJDPrintableRect))
|
||||
msg->ReplaceRect(kJDPrintableRect, fPrintableRect);
|
||||
else
|
||||
msg->RemoveName(kJDPrintableRect);
|
||||
msg->AddRect(kJDPrintableRect, fPrintableRect);
|
||||
|
||||
if (msg->HasRect(kJDScaledPrintableRect))
|
||||
msg->ReplaceRect(kJDScaledPrintableRect, fScaledPrintableRect);
|
||||
else
|
||||
msg->RemoveName(kJDScaledPrintableRect);
|
||||
msg->AddRect(kJDScaledPrintableRect, fScaledPrintableRect);
|
||||
|
||||
if (msg->HasRect(kJDPhysicalRect))
|
||||
msg->ReplaceRect(kJDPhysicalRect, fPhysicalRect);
|
||||
else
|
||||
msg->RemoveName(kJDPhysicalRect);
|
||||
msg->AddRect(kJDPhysicalRect, fPhysicalRect);
|
||||
|
||||
if (msg->HasRect(kJDScaledPhysicalRect))
|
||||
msg->ReplaceRect(kJDScaledPhysicalRect, fScaledPhysicalRect);
|
||||
else
|
||||
msg->RemoveName(kJDScaledPhysicalRect);
|
||||
msg->AddRect(kJDScaledPhysicalRect, fScaledPhysicalRect);
|
||||
|
||||
if (msg->HasInt32(kJDMarginUnit))
|
||||
msg->ReplaceInt32(kJDMarginUnit, fMarginUnit);
|
||||
else
|
||||
msg->RemoveName(kJDMarginUnit);
|
||||
msg->AddInt32(kJDMarginUnit, fMarginUnit);
|
||||
|
||||
// page settings end here; don't store job settings in message
|
||||
if (fSettings == kPageSettings) return;
|
||||
// page settings end here
|
||||
|
||||
// job settings
|
||||
if (msg->HasInt32(kJDNup))
|
||||
msg->ReplaceInt32(kJDNup, fNup);
|
||||
else
|
||||
|
||||
// make sure job settings are not present in page settings
|
||||
msg->RemoveName(kJDShowPreview);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddBool(kJDShowPreview, fShowPreview);
|
||||
|
||||
msg->RemoveName(kJDNup);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDNup, fNup);
|
||||
|
||||
if (msg->HasInt32(kJDFirstPage))
|
||||
msg->ReplaceInt32(kJDFirstPage, fFirstPage);
|
||||
else
|
||||
msg->RemoveName(kJDFirstPage);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDFirstPage, fFirstPage);
|
||||
|
||||
if (msg->HasInt32(kJDLastPage))
|
||||
msg->ReplaceInt32(kJDLastPage, fLastPage);
|
||||
else
|
||||
msg->RemoveName(kJDLastPage);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDLastPage, fLastPage);
|
||||
|
||||
if (msg->HasFloat(kJDGamma))
|
||||
msg->ReplaceFloat(kJDGamma, fGamma);
|
||||
else
|
||||
msg->RemoveName(kJDGamma);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddFloat(kJDGamma, fGamma);
|
||||
|
||||
if (msg->HasFloat(kJDInkDensity))
|
||||
msg->ReplaceFloat(kJDInkDensity, fInkDensity);
|
||||
else
|
||||
msg->RemoveName(kJDInkDensity);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddFloat(kJDInkDensity, fInkDensity);
|
||||
|
||||
if (msg->HasInt32(kJDPaperSource))
|
||||
msg->ReplaceInt32(kJDPaperSource, fPaperSource);
|
||||
else
|
||||
msg->RemoveName(kJDPaperSource);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDPaperSource, fPaperSource);
|
||||
|
||||
if (msg->HasInt32(kJDCopies))
|
||||
msg->ReplaceInt32(kJDCopies, fCopies);
|
||||
else
|
||||
msg->RemoveName(kJDCopies);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDCopies, fCopies);
|
||||
|
||||
if (msg->HasBool(kJDCollate))
|
||||
msg->ReplaceBool(kJDCollate, fCollate);
|
||||
else
|
||||
msg->RemoveName(kJDCollate);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddBool(kJDCollate, fCollate);
|
||||
|
||||
if (msg->HasBool(kJDReverse))
|
||||
msg->ReplaceBool(kJDReverse, fReverse);
|
||||
else
|
||||
msg->RemoveName(kJDReverse);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddBool(kJDReverse, fReverse);
|
||||
|
||||
if (msg->HasInt32(kJDPrintStyle))
|
||||
msg->ReplaceInt32(kJDPrintStyle, fPrintStyle);
|
||||
else
|
||||
msg->RemoveName(kJDPrintStyle);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDPrintStyle, fPrintStyle);
|
||||
|
||||
if (msg->HasInt32(kJDBindingLocation))
|
||||
msg->ReplaceInt32(kJDBindingLocation, fBindingLocation);
|
||||
else
|
||||
msg->RemoveName(kJDBindingLocation);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDBindingLocation, fBindingLocation);
|
||||
|
||||
if (msg->HasInt32(kJDPageOrder))
|
||||
msg->ReplaceInt32(kJDPageOrder, fPageOrder);
|
||||
else
|
||||
msg->RemoveName(kJDPageOrder);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDPageOrder, fPageOrder);
|
||||
|
||||
if (msg->HasBool(kJDColor))
|
||||
msg->ReplaceBool(kJDColor, fColor == kColor);
|
||||
else
|
||||
msg->AddBool(kJDColor, fColor == kColor);
|
||||
msg->RemoveName(kJDColor);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDColor, fColor);
|
||||
|
||||
if (msg->HasInt32(kJDDitherType))
|
||||
msg->ReplaceInt32(kJDDitherType, fDitherType);
|
||||
else
|
||||
msg->RemoveName(kJDDitherType);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDDitherType, fDitherType);
|
||||
|
||||
if (msg->HasInt32(kJDPageSelection))
|
||||
msg->ReplaceInt32(kJDPageSelection, fPageSelection);
|
||||
else
|
||||
msg->RemoveName(kJDPageSelection);
|
||||
if (fSettings == kJobSettings)
|
||||
msg->AddInt32(kJDPageSelection, fPageSelection);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ using namespace std;
|
||||
#define TO_HEIGHT FROM_HEIGHT
|
||||
|
||||
#define PRINT_WIDTH 365
|
||||
#define PRINT_HEIGHT QUALITY_HEIGHT + PAGERABGE_HEIGHT + 20 // 210
|
||||
#define PRINT_HEIGHT QUALITY_HEIGHT + PAGERABGE_HEIGHT + 60
|
||||
|
||||
#define PAPERFEED_H QUALITY_H + QUALITY_WIDTH + 10
|
||||
#define PAPERFEED_V QUALITY_V + 5
|
||||
@@ -173,7 +173,10 @@ using namespace std;
|
||||
#define PRINT_OK_BUTTON_H (PRINT_WIDTH - PRINT_BUTTON_WIDTH - 10)
|
||||
#define PRINT_OK_BUTTON_V (PRINT_HEIGHT - PRINT_BUTTON_HEIGHT - 11)
|
||||
|
||||
#define PRINT_CANCEL_BUTTON_H (PRINT_OK_BUTTON_H - PRINT_BUTTON_WIDTH - 12)
|
||||
#define PREVIEW_H (PRINT_OK_BUTTON_H - PRINT_BUTTON_WIDTH - 12)
|
||||
#define PREVIEW_V (PRINT_OK_BUTTON_V)
|
||||
|
||||
#define PRINT_CANCEL_BUTTON_H (PREVIEW_H - PRINT_BUTTON_WIDTH - 12)
|
||||
#define PRINT_CANCEL_BUTTON_V PRINT_OK_BUTTON_V
|
||||
|
||||
const BRect quality_rect(
|
||||
@@ -320,6 +323,14 @@ const BRect cancel_rect(
|
||||
PRINT_CANCEL_BUTTON_H + PRINT_BUTTON_WIDTH,
|
||||
PRINT_CANCEL_BUTTON_V + PRINT_BUTTON_HEIGHT);
|
||||
|
||||
const BRect preview_rect(
|
||||
PREVIEW_H,
|
||||
PREVIEW_V,
|
||||
PREVIEW_H + PRINT_BUTTON_WIDTH,
|
||||
PREVIEW_V + PRINT_BUTTON_HEIGHT);
|
||||
|
||||
|
||||
|
||||
struct SurfaceCap : public BaseCap {
|
||||
color_space surface_type;
|
||||
SurfaceCap(const string &s, bool d, color_space cs) : BaseCap(s, d), surface_type(cs) {}
|
||||
@@ -384,6 +395,7 @@ const DitherCap *gDitherTypes[] = {
|
||||
enum {
|
||||
kMsgRangeAll = 'JSdl',
|
||||
kMsgRangeSelection,
|
||||
kMsgPreview,
|
||||
kMsgCancel,
|
||||
kMsgOK,
|
||||
kMsgQuality,
|
||||
@@ -525,7 +537,7 @@ JobSetupView::AttachedToWindow()
|
||||
|
||||
fHalftone = new HalftoneView(rect.OffsetToCopy(1, 1), "halftone", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
halftoneBorder->AddChild(fHalftone);
|
||||
fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(), fJobData->getDitherType(), fJobData->getColor() == JobData::kColor);
|
||||
fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(), fJobData->getDitherType(), fJobData->getColor() != JobData::kMonochrome);
|
||||
|
||||
/* gamma */
|
||||
fGamma = new JSDSlider(gamma_rect, "gamma", "Gamma", new BMessage(kMsgQuality), -300, 300, B_BLOCK_THUMB);
|
||||
@@ -702,6 +714,14 @@ JobSetupView::AttachedToWindow()
|
||||
fOddNumberedPages = AddPageSelectionItem(pageSelectionBox, page_selection_odd_pages_rect, "oddPages", "Odd-Numbered Pages", JobData::kOddNumberedPages);
|
||||
fEvenNumberedPages = AddPageSelectionItem(pageSelectionBox, page_selection_even_pages_rect, "evenPages", "Even-Numbered Pages", JobData::kEvenNumberedPages);
|
||||
|
||||
|
||||
|
||||
/* preview */
|
||||
|
||||
button = new BButton(preview_rect, "preview", "Preview ...", new BMessage(kMsgPreview));
|
||||
AddChild(button);
|
||||
|
||||
|
||||
/* cancel */
|
||||
|
||||
button = new BButton(cancel_rect, "cancel", "Cancel", new BMessage(kMsgCancel));
|
||||
@@ -709,6 +729,7 @@ JobSetupView::AttachedToWindow()
|
||||
|
||||
/* ok */
|
||||
|
||||
// TODO OK or "Print"?
|
||||
button = new BButton(ok_rect, "ok", "OK", new BMessage(kMsgOK));
|
||||
AddChild(button);
|
||||
button->MakeDefault(true);
|
||||
@@ -741,7 +762,7 @@ JobSetupView::MessageReceived(BMessage *msg)
|
||||
break;
|
||||
|
||||
case kMsgQuality:
|
||||
fHalftone->preview(getGamma(), getInkDensity(), getDitherType(), getColor() == JobData::kColor);
|
||||
fHalftone->preview(getGamma(), getInkDensity(), getDitherType(), getColor() != JobData::kMonochrome);
|
||||
break;
|
||||
|
||||
case kMsgCollateChanged:
|
||||
@@ -799,7 +820,7 @@ JobSetupView::getInkDensity()
|
||||
}
|
||||
|
||||
bool
|
||||
JobSetupView::UpdateJobData()
|
||||
JobSetupView::UpdateJobData(bool showPreview)
|
||||
{
|
||||
int count;
|
||||
|
||||
@@ -815,6 +836,7 @@ JobSetupView::UpdateJobData()
|
||||
surface_cap++;
|
||||
}
|
||||
*/
|
||||
fJobData->setShowPreview(showPreview);
|
||||
fJobData->setColor(getColor());
|
||||
fJobData->setGamma(getGamma());
|
||||
fJobData->setInkDensity(getInkDensity());
|
||||
@@ -895,7 +917,8 @@ JobSetupDlg::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case kMsgOK:
|
||||
fJobSetup->UpdateJobData();
|
||||
case kMsgPreview:
|
||||
fJobSetup->UpdateJobData(msg->what == kMsgPreview);
|
||||
SetResult(B_NO_ERROR);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
@@ -354,10 +354,20 @@ PageSetupView::UpdateJobData()
|
||||
resolution_cap++;
|
||||
}
|
||||
|
||||
// rotate paper and physical rectangle if landscape orientation
|
||||
if (JobData::kLandscape == fJobData->getOrientation()) {
|
||||
swap(&paper_rect.left, &paper_rect.top);
|
||||
swap(&paper_rect.right, &paper_rect.bottom);
|
||||
swap(&physical_rect.left, &physical_rect.top);
|
||||
swap(&physical_rect.right, &physical_rect.bottom);
|
||||
}
|
||||
|
||||
// adjust printable rect by margin
|
||||
fJobData->setMarginUnit(fMarginView->GetMarginUnit());
|
||||
BRect margin = fMarginView->GetMargin();
|
||||
BRect printable_rect = margin;
|
||||
BRect printable_rect;
|
||||
printable_rect.left = paper_rect.left + margin.left;
|
||||
printable_rect.top = paper_rect.top + margin.top;
|
||||
printable_rect.right = paper_rect.right - margin.right;
|
||||
printable_rect.bottom = paper_rect.bottom - margin.bottom;
|
||||
|
||||
@@ -366,16 +376,6 @@ PageSetupView::UpdateJobData()
|
||||
printable_rect.right = min_c(printable_rect.right, physical_rect.right);
|
||||
printable_rect.bottom = min_c(printable_rect.bottom, physical_rect.bottom);
|
||||
|
||||
|
||||
if (JobData::kLandscape == fJobData->getOrientation()) {
|
||||
swap(&paper_rect.left, &paper_rect.top);
|
||||
swap(&paper_rect.right, &paper_rect.bottom);
|
||||
swap(&printable_rect.left, &printable_rect.top);
|
||||
swap(&printable_rect.right, &printable_rect.bottom);
|
||||
swap(&physical_rect.left, &physical_rect.top);
|
||||
swap(&physical_rect.right, &physical_rect.bottom);
|
||||
}
|
||||
|
||||
float scaling = atoi(fScaling->Text());
|
||||
if (scaling <= 0.0) { // sanity check
|
||||
scaling = 100.0;
|
||||
@@ -427,11 +427,6 @@ PageSetupDlg::PageSetupDlg(JobData *job_data, PrinterData *printer_data, const P
|
||||
"Page Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
/*
|
||||
ostringstream oss;
|
||||
oss << printer_data->get_printer_name() << " Setup";
|
||||
SetTitle(title.str().c_str());
|
||||
*/
|
||||
AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
|
||||
|
||||
PageSetupView *view = new PageSetupView(Bounds(), job_data, printer_data, printer_cap);
|
||||
|
||||
@@ -1,53 +1,619 @@
|
||||
/*
|
||||
* Preview.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
* Copyright 2002-2007, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
* Hartmut Reh
|
||||
*/
|
||||
|
||||
#include <View.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Debug.h>
|
||||
#include <String.h>
|
||||
#include "BeUtils.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include "GraphicsDriver.h"
|
||||
#include "Preview.h"
|
||||
|
||||
#ifdef USE_PREVIEW_FOR_DEBUG
|
||||
|
||||
class PreviewView : public BView {
|
||||
public:
|
||||
PreviewView(BRect, BBitmap *);
|
||||
void Draw(BRect);
|
||||
private:
|
||||
BBitmap *fBitmap;
|
||||
};
|
||||
|
||||
PreviewView::PreviewView(BRect frame, BBitmap *bitmap)
|
||||
: BView(frame, "preview", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
// Implementation of PreviewPage
|
||||
PreviewPage::PreviewPage(int32 page, PrintJobPage* pjp)
|
||||
: fPage(page)
|
||||
, fPictures(NULL)
|
||||
, fPoints(NULL)
|
||||
, fRects(NULL)
|
||||
{
|
||||
fBitmap = bitmap;
|
||||
fNumberOfPictures = pjp->NumberOfPictures();
|
||||
fPictures = new BPicture[fNumberOfPictures];
|
||||
fPoints = new BPoint[fNumberOfPictures];
|
||||
fRects = new BRect[fNumberOfPictures];
|
||||
status_t rc = B_ERROR;
|
||||
for (int32 i = 0; i < fNumberOfPictures &&
|
||||
(rc = pjp->NextPicture(fPictures[i], fPoints[i], fRects[i])) == B_OK; i ++);
|
||||
fStatus = rc;
|
||||
}
|
||||
|
||||
void PreviewView::Draw(BRect)
|
||||
{
|
||||
DrawBitmap(fBitmap);
|
||||
PreviewPage::~PreviewPage() {
|
||||
delete []fPictures;
|
||||
delete []fPoints;
|
||||
delete []fRects;
|
||||
}
|
||||
|
||||
PreviewWindow::PreviewWindow(BRect frame, const char *title, BBitmap *bitmap)
|
||||
: BWindow(frame, title, B_TITLED_WINDOW, 0)
|
||||
{
|
||||
AddChild(new PreviewView(Bounds(), bitmap));
|
||||
fSemaphore = create_sem(0, "PreviewSem");
|
||||
status_t PreviewPage::InitCheck() const {
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
bool PreviewWindow::QuitRequested()
|
||||
void PreviewPage::Draw(BView* view)
|
||||
{
|
||||
release_sem(fSemaphore);
|
||||
return true;
|
||||
ASSERT(fStatus == B_OK);
|
||||
for (int32 i = 0; i < fNumberOfPictures; i ++)
|
||||
{
|
||||
view->DrawPicture(&fPictures[i], fPoints[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int PreviewWindow::Go()
|
||||
// Implementation of PreviewView
|
||||
|
||||
const float kPreviewTopMargin = 10;
|
||||
const float kPreviewBottomMargin = 30;
|
||||
const float kPreviewLeftMargin = 10;
|
||||
const float kPreviewRightMargin = 30;
|
||||
|
||||
// TODO share constant with JobData
|
||||
static const char *kJDOrientation = "orientation";
|
||||
static const char *kJDNup = "JJJJ_nup";
|
||||
static const char *kJDReverse = "JJJJ_reverse";
|
||||
static const char* kJDPageSelection = "JJJJ_page_selection";
|
||||
|
||||
static BRect RotateRect(BRect rect)
|
||||
{
|
||||
Show();
|
||||
acquire_sem(fSemaphore);
|
||||
delete_sem(fSemaphore);
|
||||
Lock();
|
||||
BRect rotated(rect.top, rect.left, rect.bottom, rect.right);
|
||||
return rotated;
|
||||
}
|
||||
|
||||
PreviewView::PreviewView(BFile* jobFile, BRect rect)
|
||||
: BView(rect, "PreviewView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
|
||||
, fPage(0)
|
||||
, fZoom(0)
|
||||
, fReader(jobFile)
|
||||
, fNumberOfPagesPerPage(1)
|
||||
, fReverse(false)
|
||||
, fOrientation(JobData::kPortrait)
|
||||
, fPageSelection(JobData::kAllPages)
|
||||
, fCachedPage(NULL)
|
||||
{
|
||||
int32 value32;
|
||||
if (fReader.JobSettings()->FindInt32(kJDOrientation, &value32) == B_OK) {
|
||||
fOrientation = (JobData::Orientation)value32;
|
||||
}
|
||||
if (fReader.JobSettings()->FindInt32(kJDPageSelection, &value32) == B_OK) {
|
||||
fPageSelection = (JobData::PageSelection)value32;
|
||||
}
|
||||
fReader.JobSettings()->FindInt32(kJDNup, &fNumberOfPagesPerPage);
|
||||
fReader.JobSettings()->FindBool(kJDReverse, &fReverse);
|
||||
fNumberOfPages = (fReader.NumberOfPages() + fNumberOfPagesPerPage - 1) / fNumberOfPagesPerPage;
|
||||
if (fPageSelection == JobData::kOddNumberedPages) {
|
||||
fNumberOfPages = (fNumberOfPages + 1) / 2;
|
||||
}
|
||||
else if (fPageSelection == JobData::kEvenNumberedPages) {
|
||||
fNumberOfPages /= 2;
|
||||
}
|
||||
fPageRect = fReader.PaperRect();
|
||||
switch (fNumberOfPagesPerPage) {
|
||||
case 2:
|
||||
case 8:
|
||||
case 32:
|
||||
case 128:
|
||||
fPageRect = RotateRect(fPageRect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PreviewView::~PreviewView() {
|
||||
delete fCachedPage;
|
||||
}
|
||||
|
||||
// returns 2 ^ fZoom
|
||||
float PreviewView::ZoomFactor() const {
|
||||
const int32 b = 4;
|
||||
int32 zoom;
|
||||
if (fZoom > 0) {
|
||||
zoom = (1 << b) << fZoom;
|
||||
} else {
|
||||
zoom = (1 << b) >> -fZoom;
|
||||
}
|
||||
float factor = zoom / (float)(1 << b);
|
||||
return factor * fReader.GetScale() / 100.0;
|
||||
}
|
||||
|
||||
BRect PreviewView::PageRect() const {
|
||||
float f = ZoomFactor();
|
||||
BRect r(fPageRect);
|
||||
return ScaleRect(r, f);
|
||||
}
|
||||
|
||||
BRect PreviewView::PrintableRect() const {
|
||||
float f = ZoomFactor();
|
||||
BRect r = fReader.PrintableRect();
|
||||
return ScaleRect(r, f);
|
||||
}
|
||||
|
||||
BRect PreviewView::ViewRect() const {
|
||||
BRect r(PageRect());
|
||||
r.right += kPreviewLeftMargin + kPreviewRightMargin;
|
||||
r.bottom += kPreviewTopMargin + kPreviewBottomMargin;
|
||||
return r;
|
||||
}
|
||||
|
||||
status_t PreviewView::InitCheck() const {
|
||||
return fReader.InitCheck();
|
||||
}
|
||||
|
||||
bool PreviewView::IsPageLoaded(int32 page) const {
|
||||
return fCachedPage != NULL && fCachedPage->Page() == page;
|
||||
}
|
||||
|
||||
bool PreviewView::IsPageValid() const {
|
||||
return fCachedPage && fCachedPage->InitCheck() == B_OK;
|
||||
}
|
||||
|
||||
void PreviewView::LoadPage(int32 page) {
|
||||
delete fCachedPage;
|
||||
fCachedPage = NULL;
|
||||
PrintJobPage pjp;
|
||||
if (fReader.GetPage(page, pjp) == B_OK) {
|
||||
fCachedPage = new PreviewPage(page, &pjp);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::DrawPageFrame(BRect rect) {
|
||||
const float kShadowIndent = 3;
|
||||
const float kShadowWidth = 3;
|
||||
float x, y;
|
||||
float right, bottom;
|
||||
rgb_color frameColor = {0, 0, 0, 0};
|
||||
rgb_color shadowColor = {90, 90, 90, 0};
|
||||
BRect r(PageRect());
|
||||
|
||||
PushState();
|
||||
// draw page border around page
|
||||
r.InsetBy(-1, -1);
|
||||
r.OffsetTo(kPreviewLeftMargin-1, kPreviewTopMargin-1);
|
||||
SetHighColor(frameColor);
|
||||
StrokeRect(r);
|
||||
|
||||
// draw page shadow
|
||||
SetHighColor(shadowColor);
|
||||
|
||||
x = r.right + 1;
|
||||
right = x + kShadowWidth;
|
||||
bottom = r.bottom + 1 + kShadowWidth;
|
||||
y = r.top + kShadowIndent;
|
||||
FillRect(BRect(x, y, right, bottom));
|
||||
|
||||
x = r.left + kShadowIndent;
|
||||
y = r.bottom + 1;
|
||||
FillRect(BRect(x, y, r.right, bottom));
|
||||
PopState();
|
||||
}
|
||||
|
||||
|
||||
int32 PreviewView::GetPageNumber(int32 index) const
|
||||
{
|
||||
int page = fPage;
|
||||
if (fReverse) {
|
||||
page = fNumberOfPages - fPage - 1;
|
||||
}
|
||||
|
||||
if (fPageSelection == JobData::kOddNumberedPages) {
|
||||
page *= 2; // 0, 2, 4, ...
|
||||
}
|
||||
else if (fPageSelection == JobData::kEvenNumberedPages) {
|
||||
page = 2 * page + 1; // 1, 3, 5, ...
|
||||
}
|
||||
|
||||
return page * fNumberOfPagesPerPage + index;
|
||||
}
|
||||
|
||||
void PreviewView::DrawPage(BRect rect)
|
||||
{
|
||||
|
||||
BRect physicalRect = fReader.PaperRect();
|
||||
BRect scaledPhysicalRect = physicalRect;
|
||||
BRect scaledPrintableRect = fReader.PrintableRect();
|
||||
|
||||
for (int32 index = 0; index < fNumberOfPagesPerPage; index ++) {
|
||||
int32 pageNumber = GetPageNumber(index);
|
||||
if (pageNumber < 0) {
|
||||
// no page at index
|
||||
continue;
|
||||
}
|
||||
if (!IsPageLoaded(pageNumber)) {
|
||||
LoadPage(pageNumber);
|
||||
}
|
||||
if (!IsPageValid()) {
|
||||
// TODO show feedback
|
||||
continue;
|
||||
}
|
||||
|
||||
BPoint scalingXY = GraphicsDriver::getScale(fNumberOfPagesPerPage, physicalRect, 100.0);
|
||||
float scaling = min_c(scalingXY.x, scalingXY.y);
|
||||
BPoint offset = GraphicsDriver::getOffset(fNumberOfPagesPerPage, index, fOrientation, &scalingXY,
|
||||
scaledPhysicalRect, scaledPrintableRect, physicalRect);
|
||||
|
||||
// draw page contents
|
||||
PushState();
|
||||
|
||||
// print job coordinates are relative to the printable rect
|
||||
SetScale(ZoomFactor() * scaling);
|
||||
|
||||
BPoint leftTopMargin(BPoint(kPreviewLeftMargin, kPreviewTopMargin));
|
||||
leftTopMargin.x /= ZoomFactor() * scaling;
|
||||
leftTopMargin.y /= ZoomFactor() * scaling;
|
||||
offset += leftTopMargin;
|
||||
SetOrigin(offset);
|
||||
|
||||
// constrain clipping region to printable rectangle
|
||||
BRect clipRect(fReader.PrintableRect());
|
||||
clipRect.OffsetTo(0, 0);
|
||||
BRegion clip(clipRect);
|
||||
ConstrainClippingRegion(&clip);
|
||||
|
||||
fCachedPage->Draw(this);
|
||||
|
||||
PopState();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::Draw(BRect rect) {
|
||||
if (fReader.InitCheck() == B_OK) {
|
||||
DrawPageFrame(rect);
|
||||
DrawPage(rect);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::FrameResized(float width, float height) {
|
||||
FixScrollbars();
|
||||
}
|
||||
|
||||
bool PreviewView::ShowsFirstPage() const {
|
||||
return fPage == 0;
|
||||
}
|
||||
|
||||
bool PreviewView::ShowsLastPage() const {
|
||||
return fPage == NumberOfPages() - 1;
|
||||
}
|
||||
|
||||
int PreviewView::NumberOfPages() const {
|
||||
return fNumberOfPages;
|
||||
}
|
||||
|
||||
void PreviewView::ShowNextPage() {
|
||||
if (!ShowsLastPage()) {
|
||||
fPage ++;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::ShowPrevPage() {
|
||||
if (!ShowsFirstPage()) {
|
||||
fPage --;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::ShowFirstPage() {
|
||||
if (!ShowsFirstPage()) {
|
||||
fPage = 0;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::ShowLastPage() {
|
||||
if (!ShowsLastPage()) {
|
||||
fPage = NumberOfPages()-1;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::ShowFindPage(int page) {
|
||||
page --;
|
||||
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
} else if (page > (NumberOfPages()-1)) {
|
||||
page = NumberOfPages()-1;
|
||||
}
|
||||
|
||||
fPage = (int32)page;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
bool PreviewView::CanZoomIn() const {
|
||||
return fZoom < 4;
|
||||
}
|
||||
|
||||
bool PreviewView::CanZoomOut() const {
|
||||
return fZoom > -2;
|
||||
}
|
||||
|
||||
void PreviewView::ZoomIn() {
|
||||
if (CanZoomIn()) {
|
||||
fZoom ++; FixScrollbars();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::ZoomOut() {
|
||||
if (CanZoomOut()) {
|
||||
fZoom --; FixScrollbars();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::FixScrollbars() {
|
||||
BRect frame = Bounds();
|
||||
BScrollBar * scroll;
|
||||
float x, y;
|
||||
float bigStep, smallStep;
|
||||
float width = PageRect().Width() + kPreviewLeftMargin + kPreviewRightMargin;
|
||||
float height = PageRect().Height() + kPreviewTopMargin + kPreviewBottomMargin;
|
||||
x = width - frame.Width();
|
||||
if (x < 0.0) {
|
||||
x = 0.0;
|
||||
}
|
||||
y = height - frame.Height();
|
||||
if (y < 0.0) {
|
||||
y = 0.0;
|
||||
}
|
||||
|
||||
scroll = ScrollBar (B_HORIZONTAL);
|
||||
scroll->SetRange (0.0, x);
|
||||
scroll->SetProportion ((width - x) / width);
|
||||
bigStep = frame.Width() - 2;
|
||||
smallStep = bigStep / 10.;
|
||||
scroll->SetSteps (smallStep, bigStep);
|
||||
|
||||
scroll = ScrollBar (B_VERTICAL);
|
||||
scroll->SetRange (0.0, y);
|
||||
scroll->SetProportion ((height - y) / height);
|
||||
bigStep = frame.Height() - 2;
|
||||
smallStep = bigStep / 10.;
|
||||
scroll->SetSteps (smallStep, bigStep);
|
||||
}
|
||||
|
||||
// Implementation of PreviewWindow
|
||||
|
||||
PreviewWindow::PreviewWindow(BFile* jobFile, bool showOkAndCancelButtons)
|
||||
: BlockingWindow(BRect(20, 24, 400, 600), "Preview", B_DOCUMENT_WINDOW, 0)
|
||||
{
|
||||
const float kButtonDistance = 15;
|
||||
const float kPageTextDistance = 10;
|
||||
const float kVerticalIndent = 7;
|
||||
const float kHorizontalIndent = 20;
|
||||
|
||||
float top = kVerticalIndent;
|
||||
float left = kHorizontalIndent;
|
||||
float width, height;
|
||||
|
||||
BRect r = Frame();
|
||||
r.right = r.IntegerWidth() - B_V_SCROLL_BAR_WIDTH; r.left = 0;
|
||||
r.bottom = r.IntegerHeight() - B_H_SCROLL_BAR_HEIGHT; r.top = 0;
|
||||
|
||||
// add navigation and zoom buttons
|
||||
fFirst = new BButton(BRect(left, top, left+10, top+10), "First", "First Page", new BMessage(MSG_FIRST_PAGE));
|
||||
AddChild(fFirst);
|
||||
|
||||
fPrev = new BButton(BRect(left, top, left+10, top+10), "Prev", "Previous Page", new BMessage(MSG_PREV_PAGE));
|
||||
AddChild(fPrev);
|
||||
fPrev->ResizeToPreferred();
|
||||
// remember size of largest button
|
||||
width = fPrev->Bounds().Width()+1;
|
||||
height = fPrev->Bounds().Height()+1;
|
||||
|
||||
fFirst->ResizeTo(width, height);
|
||||
left = fFirst->Frame().right + kButtonDistance;
|
||||
|
||||
// move Previous Page button after First Page button
|
||||
fPrev->MoveTo(left, top);
|
||||
left = fPrev->Frame().right + kButtonDistance;
|
||||
|
||||
fNext = new BButton(BRect(left, top, left+10, top+10), "Next", "Next Page", new BMessage(MSG_NEXT_PAGE));
|
||||
AddChild(fNext);
|
||||
fNext->ResizeTo(width, height);
|
||||
left = fNext->Frame().right + kButtonDistance;
|
||||
|
||||
fLast = new BButton(BRect(left, top, left+10, top+10), "Last", "Last Page", new BMessage(MSG_LAST_PAGE));
|
||||
AddChild(fLast);
|
||||
fLast->ResizeTo(width, height);
|
||||
left = fLast->Frame().right + kPageTextDistance;
|
||||
|
||||
// page number text
|
||||
fPageNumber = new BTextControl(BRect(left, top+3, left+10, top+10), "FindPage", "", "", new BMessage(MSG_FIND_PAGE));
|
||||
fPageNumber->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
|
||||
int num;
|
||||
for (num = 0; num <= 255; num++) {
|
||||
fPageNumber->TextView()->DisallowChar(num);
|
||||
}
|
||||
for (num = 0; num <= 9; num++) {
|
||||
fPageNumber->TextView()->AllowChar('0' + num);
|
||||
}
|
||||
fPageNumber->TextView()-> SetMaxBytes(5);
|
||||
AddChild(fPageNumber);
|
||||
fPageNumber->ResizeTo(be_plain_font->StringWidth("999999") + 10, height);
|
||||
left = fPageNumber->Frame().right + 5;
|
||||
|
||||
// number of pages text
|
||||
fPageText = new BStringView(BRect(left, top, left + 100, top + 15), "pageText", "");
|
||||
AddChild(fPageText);
|
||||
// estimate max. width
|
||||
float pageTextWidth = fPageText->StringWidth("of 99999 Pages");
|
||||
// estimate height
|
||||
BFont font;
|
||||
fPageText->GetFont(&font);
|
||||
float pageTextHeight = font.Size() + 2;
|
||||
// resize to estimated size
|
||||
fPageText->ResizeTo(pageTextWidth, pageTextHeight);
|
||||
left += pageTextWidth + kPageTextDistance;
|
||||
fPageText->MoveBy(0, (height - font.Size()) / 2);
|
||||
|
||||
|
||||
fZoomIn = new BButton(BRect(left, top, left+10, top+10), "ZoomIn", "Zoom In", new BMessage(MSG_ZOOM_IN));
|
||||
AddChild(fZoomIn);
|
||||
fZoomIn->ResizeTo(width, height);
|
||||
left = fZoomIn->Frame().right + kButtonDistance;
|
||||
|
||||
fZoomOut = new BButton(BRect(left, top, left+10, top+10), "ZoomOut", "Zoom Out", new BMessage(MSG_ZOOM_OUT));
|
||||
AddChild(fZoomOut);
|
||||
fZoomOut->ResizeTo(width, height);
|
||||
|
||||
fButtonBarHeight = fZoomOut->Frame().bottom + 7;
|
||||
float bottomOfTopButtonBar = fButtonBarHeight;
|
||||
|
||||
if (showOkAndCancelButtons) {
|
||||
// cancel printing if user closes the preview window
|
||||
SetUserQuitResult(B_ERROR);
|
||||
|
||||
// add another button bar at bottom of window
|
||||
r.bottom -= fButtonBarHeight;
|
||||
// update the total height of both bars
|
||||
fButtonBarHeight *= 2;
|
||||
|
||||
// right align buttons
|
||||
left = r.Width() - width - kHorizontalIndent;
|
||||
top = r.Height() + kVerticalIndent + B_H_SCROLL_BAR_HEIGHT;
|
||||
|
||||
left -= width + kButtonDistance;
|
||||
BButton *printJob = new BButton(BRect(left, top+2, left+10, top+12), "PrintJob", "Print", new BMessage(MSG_PRINT_JOB), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
printJob->MakeDefault(true);
|
||||
AddChild(printJob);
|
||||
printJob->ResizeTo(width+4, height+4);
|
||||
|
||||
left += width + kButtonDistance;
|
||||
BButton *cancelJob = new BButton(BRect(left, top, left+10, top+10), "CancelJob", "Cancel", new BMessage(MSG_CANCEL_JOB), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
AddChild(cancelJob);
|
||||
cancelJob->ResizeTo(width, height);
|
||||
}
|
||||
|
||||
|
||||
// add preview view
|
||||
r.top = bottomOfTopButtonBar;
|
||||
fPreview = new PreviewView(jobFile, r);
|
||||
|
||||
|
||||
fPreviewScroller = new BScrollView("PreviewScroller", fPreview, B_FOLLOW_ALL, 0, true, true, B_FANCY_BORDER);
|
||||
fPreviewScroller->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(fPreviewScroller);
|
||||
|
||||
if (fPreview->InitCheck() == B_OK) {
|
||||
ResizeToPage(true);
|
||||
fPreview->FixScrollbars();
|
||||
UpdateControls();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewWindow::ResizeToPage(bool allowShrinking) {
|
||||
BScreen screen;
|
||||
BRect r(fPreview->ViewRect());
|
||||
float width, height;
|
||||
float maxWidth, maxHeight, minWidth;
|
||||
const float windowBorderWidth = 5;
|
||||
const float windowBorderHeight = 5;
|
||||
|
||||
if (screen.Frame().right == 0.0) {
|
||||
return; // invalid screen object
|
||||
}
|
||||
|
||||
width = r.Width() + 1 + B_V_SCROLL_BAR_WIDTH;
|
||||
height = r.Height() + 1 + fButtonBarHeight + B_H_SCROLL_BAR_HEIGHT;
|
||||
|
||||
// dimensions so that window does not reach outside of screen
|
||||
maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left;
|
||||
maxHeight = screen.Frame().Height() + 1 - windowBorderHeight - Frame().top;
|
||||
|
||||
// width so that all buttons are visible
|
||||
minWidth = fZoomOut->Frame().right + 10;
|
||||
|
||||
if (width < minWidth) width = minWidth;
|
||||
|
||||
if (width > maxWidth) width = maxWidth;
|
||||
if (height > maxHeight) height = maxHeight;
|
||||
|
||||
if (!allowShrinking) {
|
||||
if (Bounds().Width() > width) width = Bounds().Width();
|
||||
if (Bounds().Height() > height) height = Bounds().Height();
|
||||
}
|
||||
ResizeTo(width, height);
|
||||
}
|
||||
|
||||
void PreviewWindow::UpdateControls() {
|
||||
fFirst->SetEnabled(!fPreview->ShowsFirstPage());
|
||||
fPrev->SetEnabled(!fPreview->ShowsFirstPage());
|
||||
fNext->SetEnabled(!fPreview->ShowsLastPage());
|
||||
fLast->SetEnabled(!fPreview->ShowsLastPage());
|
||||
fZoomIn->SetEnabled(fPreview->CanZoomIn());
|
||||
fZoomOut->SetEnabled(fPreview->CanZoomOut());
|
||||
|
||||
BString page;
|
||||
page << fPreview->CurrentPage();
|
||||
fPageNumber->SetText(page.String());
|
||||
|
||||
BString text;
|
||||
text << "of "
|
||||
<< fPreview->NumberOfPages();
|
||||
if (fPreview->NumberOfPages() == 1) {
|
||||
text << " Page";
|
||||
} else {
|
||||
text << " Pages";
|
||||
}
|
||||
fPageText->SetText(text.String());}
|
||||
|
||||
void PreviewWindow::MessageReceived(BMessage* m) {
|
||||
switch (m->what) {
|
||||
case MSG_FIRST_PAGE:
|
||||
fPreview->ShowFirstPage();
|
||||
break;
|
||||
case MSG_NEXT_PAGE:
|
||||
fPreview->ShowNextPage();
|
||||
break;
|
||||
case MSG_PREV_PAGE:
|
||||
fPreview->ShowPrevPage();
|
||||
break;
|
||||
case MSG_LAST_PAGE:
|
||||
fPreview->ShowLastPage();
|
||||
break;
|
||||
case MSG_FIND_PAGE:
|
||||
fPreview->ShowFindPage(atoi(fPageNumber->Text())) ;
|
||||
break;
|
||||
case MSG_ZOOM_IN:
|
||||
fPreview->ZoomIn();
|
||||
ResizeToPage();
|
||||
break;
|
||||
case MSG_ZOOM_OUT:
|
||||
fPreview->ZoomOut();
|
||||
ResizeToPage();
|
||||
break;
|
||||
case MSG_CANCEL_JOB:
|
||||
Quit(B_ERROR);
|
||||
break;
|
||||
case MSG_PRINT_JOB:
|
||||
Quit(B_OK);
|
||||
break;
|
||||
|
||||
default:
|
||||
inherited::MessageReceived(m); return;
|
||||
}
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
status_t PreviewWindow::Go() {
|
||||
status_t st = InitCheck();
|
||||
if (st == B_OK) {
|
||||
return inherited::Go();
|
||||
} else {
|
||||
Quit();
|
||||
return 0;
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
#endif /* USE_PREVIEW_FOR_DEBUG */
|
||||
|
||||
@@ -34,6 +34,7 @@ void PrinterData::load()
|
||||
char buffer[512];
|
||||
|
||||
fNode->ReadAttr(PD_DRIVER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
|
||||
// TODO fix possible buffer overrun (not terminated string).
|
||||
fDriverName = buffer;
|
||||
fNode->ReadAttr(PD_PRINTER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
|
||||
fPrinterName = buffer;
|
||||
@@ -41,14 +42,18 @@ void PrinterData::load()
|
||||
fComments = buffer;
|
||||
fNode->ReadAttr(PD_TRANSPORT, B_STRING_TYPE, 0, buffer, sizeof(buffer));
|
||||
fTransport = buffer;
|
||||
fNode->ReadAttr(PD_PROTOCOL_CLASS, B_BOOL_TYPE, 0, &fProtocolClass, sizeof(fProtocolClass));
|
||||
|
||||
int32 valueI32;
|
||||
fNode->ReadAttr(PD_PROTOCOL_CLASS, B_INT32_TYPE, 0, &valueI32, sizeof(valueI32));
|
||||
fProtocolClass = (int)valueI32;
|
||||
}
|
||||
|
||||
void PrinterData::save()
|
||||
{
|
||||
if (fNode == NULL) return;
|
||||
|
||||
fNode->WriteAttr(PD_PROTOCOL_CLASS, B_BOOL_TYPE, 0, &fProtocolClass, sizeof(fProtocolClass));
|
||||
int32 valueI32 = (int32)fProtocolClass;
|
||||
fNode->WriteAttr(PD_PROTOCOL_CLASS, B_INT32_TYPE, 0, &valueI32, sizeof(valueI32));
|
||||
}
|
||||
|
||||
bool PrinterData::getPath(string &path) const
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "PrinterCap.h"
|
||||
#include "PrinterData.h"
|
||||
#include "UIDriver.h"
|
||||
#include "Preview.h"
|
||||
|
||||
|
||||
// Implementation of PrinterDriver
|
||||
@@ -138,6 +139,13 @@ PrinterDriver::TakeJob(BFile* printJob, BMessage* settings)
|
||||
DUMP_BNODE(fSpoolFolder);
|
||||
|
||||
fGraphicsDriver = InstantiateGraphicsDriver(settings, fPrinterData, fPrinterCap);
|
||||
const JobData* jobData = fGraphicsDriver->getJobData(printJob);
|
||||
if (jobData != NULL && jobData->getShowPreview()) {
|
||||
PreviewWindow *preview = new PreviewWindow(printJob, true);
|
||||
if (preview->Go() != B_OK) {
|
||||
return new BMessage('okok');
|
||||
}
|
||||
}
|
||||
BMessage *result = fGraphicsDriver->takeJob(printJob);
|
||||
|
||||
DUMP_BMESSAGE(result);
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright 2005-2006, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Dr.H.Reh
|
||||
*/
|
||||
|
||||
#include "StatusWindow.h"
|
||||
#include <Message.h>
|
||||
#include <View.h>
|
||||
#include <StatusBar.h>
|
||||
#include <Button.h>
|
||||
#include <stdio.h>
|
||||
#include <StringView.h>
|
||||
|
||||
|
||||
#define CANCEL_MSG 'canM'
|
||||
#define HIDE_MSG 'hidM'
|
||||
|
||||
|
||||
StatusWindow::StatusWindow(bool oddPages, bool evenPages, uint32 firstPage, uint32 numPages, uint32 numCopies, uint32 nup)
|
||||
: BWindow (BRect(200, 200, 650, 270), "Print Status", B_DOCUMENT_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
// oddPages - if true, only print odd umbered pages
|
||||
// evenPages - if true, only print even umbered pages
|
||||
// firstPage - number of first page
|
||||
// numPages - total number of pages (must be recalculate if odd/even is used)
|
||||
// numCopies - total number of document copies
|
||||
|
||||
BRect frame = Frame();
|
||||
// the status view
|
||||
frame.OffsetTo(B_ORIGIN);
|
||||
fStatusView = new BView(frame,"Status View",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
fStatusView->SetViewColor(216,216,216);
|
||||
AddChild(fStatusView);
|
||||
|
||||
// the status bar
|
||||
fStatusBar = new BStatusBar(BRect(10, 15, 245, 50),"Status Bar","Page: ");
|
||||
fStatusView->AddChild(fStatusBar);
|
||||
|
||||
// the cancel button
|
||||
fHideButton = new BButton(BRect(260, 25, 330,50),"Hide Button","Hide Status", new BMessage(HIDE_MSG));
|
||||
fHideButton->ResizeToPreferred();
|
||||
fStatusView->AddChild(fHideButton);
|
||||
|
||||
fCancelButton = new BButton(BRect(260, 25, 330,50),"Cancel Button","Cancel", new BMessage(CANCEL_MSG));
|
||||
fCancelButton->ResizeToPreferred();
|
||||
fCancelButton->MoveBy(90,0);
|
||||
|
||||
fStatusView->AddChild(fCancelButton);
|
||||
|
||||
fCancelBar = false;
|
||||
|
||||
// calculate the real number of pages
|
||||
fNops = numPages;
|
||||
|
||||
bool evenFirstPage = (firstPage % 2) == 0;
|
||||
bool evenNumPages = (numPages % 2) == 0;
|
||||
|
||||
// recalculate page numbers if even or odd is used
|
||||
if (oddPages || evenPages) {
|
||||
if (evenNumPages) {
|
||||
fNops = numPages / 2;
|
||||
} else if (evenFirstPage) {
|
||||
if (oddPages)
|
||||
fNops = (numPages - 1) / 2;
|
||||
if (evenPages)
|
||||
fNops = (numPages + 1) / 2;
|
||||
} else {
|
||||
if (oddPages)
|
||||
fNops = (numPages + 1) / 2;
|
||||
if (evenPages)
|
||||
fNops = (numPages - 1) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 addPage = 0;
|
||||
if (fNops % nup > 0)
|
||||
addPage = 1;
|
||||
fNops = (uint32) ( fNops/(float)nup ) + addPage;
|
||||
// recalculate page numbers nup-pages-up
|
||||
|
||||
fStatusBar->SetMaxValue ((float)fNops);
|
||||
// max value of status bar = real number of pages
|
||||
fDelta = 1.0/numCopies;
|
||||
// reduce step width of status bar
|
||||
fStatusDelta = fDelta;
|
||||
fDocCopies = numCopies;
|
||||
|
||||
fDocumentCopy = fDocCopies > 1;
|
||||
|
||||
fDocCopies++;
|
||||
|
||||
ResetStatusBar();
|
||||
Show();
|
||||
}
|
||||
|
||||
|
||||
StatusWindow::~StatusWindow(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StatusWindow::ResetStatusBar(void)
|
||||
{
|
||||
Lock();
|
||||
fStatusBar->Reset("Page: ");
|
||||
Unlock();
|
||||
}
|
||||
|
||||
bool
|
||||
StatusWindow::UpdateStatusBar(uint32 page, uint32 copy)
|
||||
{
|
||||
Lock();
|
||||
Activate(true);
|
||||
// Frontmost Window
|
||||
char buffer[20];
|
||||
|
||||
sprintf(buffer,"%d", (int)(page + 1));
|
||||
BString string1(buffer);
|
||||
|
||||
sprintf(buffer,"%d",(int)fNops );
|
||||
BString string2(buffer);
|
||||
string1.Append(BString(" / "));
|
||||
string1.Append(string2);
|
||||
|
||||
BString string3 = BString("Remaining Document Copies: ");
|
||||
if (fDocumentCopy == true) {
|
||||
sprintf(buffer, "%d", (int)(fDocCopies));
|
||||
BString string4(buffer);
|
||||
string3.Append(string4);
|
||||
} else {
|
||||
string3 = BString("Remaining Page Copies: ");
|
||||
char buffer[20];
|
||||
sprintf(buffer,"%d",(int)(fCopies - copy) );
|
||||
BString string4(buffer);
|
||||
string3.Append(string4);
|
||||
}
|
||||
|
||||
fStatusBar->Update(fStatusDelta*100.0/fNops, string1.String(), string3.String());
|
||||
if ( (fStatusBar->MaxValue()) == (fStatusBar->CurrentValue()) )
|
||||
fCancelButton->SetEnabled(false);
|
||||
Unlock();
|
||||
return fCancelBar;
|
||||
}
|
||||
|
||||
void
|
||||
StatusWindow::SetPageCopies(uint32 copies)
|
||||
{
|
||||
fCopies = copies;
|
||||
fStatusDelta = fDelta/(float)fCopies;
|
||||
fDocCopies--;
|
||||
}
|
||||
|
||||
|
||||
// Handling of user interface and other events
|
||||
void
|
||||
StatusWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
|
||||
switch(message->what) {
|
||||
case CANCEL_MSG: // 'CancelButton' is pressed...
|
||||
{
|
||||
fCancelBar = true;
|
||||
fCancelButton->SetEnabled(false);
|
||||
fCancelButton->SetLabel("Job cancelled");
|
||||
}
|
||||
break;
|
||||
|
||||
case HIDE_MSG: // 'HideButton' is pressed...
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
inherited::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
+13
-2
@@ -74,7 +74,12 @@ HWindow::MessageReceived(BMessage* msg)
|
||||
void
|
||||
HWindow::AboutRequested()
|
||||
{
|
||||
BAlert *about = new BAlert("About Preview", kAbout, "Cool");
|
||||
const char* aboutText = AboutText();
|
||||
if (aboutText == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
BAlert *about = new BAlert("About", aboutText, "Cool");
|
||||
BTextView *v = about->TextView();
|
||||
if (v) {
|
||||
rgb_color red = {255, 0, 51, 255};
|
||||
@@ -123,6 +128,7 @@ BlockingWindow::~BlockingWindow()
|
||||
void
|
||||
BlockingWindow::Init(const char* title)
|
||||
{
|
||||
fUserQuitResult = B_OK;
|
||||
fResult = NULL;
|
||||
fExitSem = create_sem(0, title);
|
||||
fReadyToQuit = false;
|
||||
@@ -134,7 +140,7 @@ BlockingWindow::QuitRequested() {
|
||||
return true;
|
||||
} else {
|
||||
// user requested to quit the window
|
||||
*fResult = B_OK;
|
||||
*fResult = fUserQuitResult;
|
||||
release_sem(fExitSem);
|
||||
return false;
|
||||
}
|
||||
@@ -154,6 +160,11 @@ BlockingWindow::Quit(status_t result) {
|
||||
release_sem(fExitSem);
|
||||
}
|
||||
|
||||
void
|
||||
BlockingWindow::SetUserQuitResult(status_t result) {
|
||||
fUserQuitResult = result;
|
||||
}
|
||||
|
||||
status_t
|
||||
BlockingWindow::Go() {
|
||||
status_t result = B_ERROR;
|
||||
@@ -0,0 +1,12 @@
|
||||
SubDir HAIKU_TOP src add-ons print drivers shared utils ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
|
||||
|
||||
StaticLibrary libprintutils.a :
|
||||
InterfaceUtils.cpp
|
||||
MarginView.cpp
|
||||
Utils.cpp
|
||||
;
|
||||
|
||||
+4
-4
@@ -33,9 +33,7 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MARGIN_VIEW_H
|
||||
#include "MarginView.h"
|
||||
#endif
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <SupportKit.h>
|
||||
@@ -659,8 +657,10 @@ MarginView::CalculateViewSize(uint32 msg)
|
||||
float fleft = atof(fLeft->Text()) * fUnitValue;
|
||||
|
||||
// Check that the margins don't overlap each other...
|
||||
float ph = fPageHeight;
|
||||
float pw = fPageWidth;
|
||||
float delta = 72.0;
|
||||
// minimum printable rect = 1 inch * 1 inch
|
||||
float ph = fPageHeight-delta;
|
||||
float pw = fPageWidth-delta;
|
||||
BString str;
|
||||
|
||||
// Bounds calculation rules:
|
||||
-53
@@ -30,9 +30,7 @@ THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "Utils.h"
|
||||
#include <string.h>
|
||||
|
||||
// --------------------------------------------------
|
||||
EscapeMessageFilter::EscapeMessageFilter(BWindow *window, int32 what)
|
||||
@@ -56,49 +54,6 @@ EscapeMessageFilter::Filter(BMessage *msg, BHandler **target)
|
||||
return B_DISPATCH_MESSAGE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// copied from BeUtils.cpp
|
||||
static bool InList(const char* list[], const char* name) {
|
||||
for (int i = 0; list[i] != NULL; i ++) {
|
||||
if (strcmp(list[i], name) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// --------------------------------------------------
|
||||
// copied from BeUtils.cpp
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[], const char* includeList[]) {
|
||||
if (to == from) return;
|
||||
char* name;
|
||||
type_code type;
|
||||
int32 count;
|
||||
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
||||
if (excludeList && InList(excludeList, name)) continue;
|
||||
if (includeList && !InList(includeList, name)) continue;
|
||||
// replace existing data
|
||||
to->RemoveName(name);
|
||||
|
||||
const void* data;
|
||||
ssize_t size;
|
||||
for (int32 j = 0; j < count; j ++) {
|
||||
if (from->FindData(name, type, j, &data, &size) == B_OK) {
|
||||
// WTF why works AddData not for B_STRING_TYPE in R5.0.3?
|
||||
if (type == B_STRING_TYPE) {
|
||||
to->AddString(name, (const char*)data);
|
||||
} else if (type == B_MESSAGE_TYPE) {
|
||||
BMessage m;
|
||||
from->FindMessage(name, j, &m);
|
||||
to->AddMessage(name, &m);
|
||||
} else {
|
||||
to->AddData(name, type, data, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddString(BMessage* m, const char* name, const char* value) {
|
||||
if (m->HasString(name, 0)) {
|
||||
m->ReplaceString(name, value);
|
||||
@@ -130,11 +85,3 @@ void SetInt32(BMessage* msg, const char* name, int32 value) {
|
||||
msg->AddInt32(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
BRect ScaleRect(BRect rect, float scale) {
|
||||
rect.left *= scale;
|
||||
rect.right *= scale;
|
||||
rect.top *= scale;
|
||||
rect.bottom *= scale;
|
||||
return rect;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
UsePrivateHeaders interface print ;
|
||||
|
||||
StaticLibrary
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
:
|
||||
PicturePrinter.cpp
|
||||
PrintJobReader.cpp
|
||||
|
||||
@@ -96,13 +96,15 @@ void LprSetupView::AttachedToWindow()
|
||||
|
||||
/* server name box */
|
||||
|
||||
server = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "", NULL);
|
||||
// TODO remember previous value
|
||||
server = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0", NULL);
|
||||
AddChild(server);
|
||||
server->SetDivider(width);
|
||||
|
||||
/* queue name box */
|
||||
|
||||
queue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "", NULL);
|
||||
// TODO remember previous value
|
||||
queue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU", NULL);
|
||||
AddChild(queue);
|
||||
queue->SetDivider(width);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ LinkAgainst
|
||||
be
|
||||
root
|
||||
translation
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
;
|
||||
|
||||
Package haiku-printingkit-cvs :
|
||||
|
||||
@@ -101,27 +101,35 @@ static bool InList(const char* list[], const char* name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[], const char* includeList[]) {
|
||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[], const char* includeList[], bool overwrite) {
|
||||
if (to == from) return;
|
||||
char* name;
|
||||
type_code type;
|
||||
int32 count;
|
||||
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
||||
const void* data;
|
||||
ssize_t size;
|
||||
|
||||
if (excludeList && InList(excludeList, name)) continue;
|
||||
if (includeList && !InList(includeList, name)) continue;
|
||||
|
||||
if (!overwrite && to->FindData(name, type, 0, &data, &size) == B_OK) {
|
||||
continue;
|
||||
}
|
||||
// replace existing data
|
||||
to->RemoveName(name);
|
||||
|
||||
const void* data;
|
||||
ssize_t size;
|
||||
for (int32 j = 0; j < count; j ++) {
|
||||
if (from->FindData(name, type, j, &data, &size) == B_OK) {
|
||||
if (type == B_STRING_TYPE) to->AddString(name, (const char*)data);
|
||||
else if (type == B_MESSAGE_TYPE) {
|
||||
if (type == B_STRING_TYPE) {
|
||||
to->AddString(name, (const char*)data);
|
||||
} else if (type == B_MESSAGE_TYPE) {
|
||||
BMessage m;
|
||||
from->FindMessage(name, j, &m);
|
||||
to->AddMessage(name, &m);
|
||||
} else to->AddData(name, type, data, size);
|
||||
} else {
|
||||
to->AddData(name, type, data, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
UsePrivateHeaders shared interface print ;
|
||||
|
||||
StaticLibrary
|
||||
libprint.a
|
||||
libprintutils.a
|
||||
:
|
||||
BeUtils.cpp
|
||||
BeUtilsTranslation.cpp
|
||||
|
||||
Reference in New Issue
Block a user