* move libprint sources into libs, as it is a 3rdparty lib

* move libprint headers into libs headers folder accordingly
* merge all shared folders sources into kits print, we might build later on a
  real print kit, propably also to access cups from an nicely API, atm static
* move all shared headers into private print, also pr_server.h from interface
* adjust build to work with the changed folder layout



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26570 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2008-07-22 20:30:14 +00:00
parent 467acc16f5
commit 12fd6cc2e7
93 changed files with 724 additions and 571 deletions
@@ -1,16 +1,16 @@
/*
* AboutBox.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __ABOUTBOX_H
#define __ABOUTBOX_H
#include <Application.h>
class AboutBox : public BApplication {
public:
AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright);
};
#endif /* __ABOUTBOX_H */
/*
* AboutBox.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __ABOUTBOX_H
#define __ABOUTBOX_H
#include <Application.h>
class AboutBox : public BApplication {
public:
AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright);
};
#endif /* __ABOUTBOX_H */
@@ -1,22 +1,22 @@
/*
* Exports.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __EXPORTS_H
#define __EXPORTS_H
#include <BeBuild.h>
class BNode;
class BMessage;
class BFile;
extern "C" {
_EXPORT char *add_printer(char *printer_name);
_EXPORT BMessage *config_page(BNode *node, BMessage *msg);
_EXPORT BMessage *config_job(BNode *node, BMessage *msg);
_EXPORT BMessage *take_job(BFile *spool_file, BNode *node, BMessage *msg);
}
#endif // __EXPORTS_H
/*
* Exports.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __EXPORTS_H
#define __EXPORTS_H
#include <BeBuild.h>
class BNode;
class BMessage;
class BFile;
extern "C" {
_EXPORT char *add_printer(char *printer_name);
_EXPORT BMessage *config_page(BNode *node, BMessage *msg);
_EXPORT BMessage *config_job(BNode *node, BMessage *msg);
_EXPORT BMessage *take_job(BFile *spool_file, BNode *node, BMessage *msg);
}
#endif // __EXPORTS_H
@@ -1,57 +1,57 @@
/*
* Transport.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __TRANSPORT_H
#define __TRANSPORT_H
#include <image.h>
#include <string>
class BDataIO;
class PrinterData;
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
extern "C" {
typedef BDataIO *(*PFN_init_transport)(BMessage *);
typedef void (*PFN_exit_transport)(void);
}
class TransportException {
private:
string fWhat;
public:
TransportException(const string &what_arg) : fWhat(what_arg) {}
const char *what() const { return fWhat.c_str(); }
};
class Transport {
public:
Transport(const PrinterData *printer_data);
~Transport();
void write(const void *buffer, size_t size) throw(TransportException);
bool check_abort() const;
bool is_print_to_file_canceled() const;
const string &last_error() const;
protected:
void set_last_error(const char *e);
Transport(const Transport &);
Transport &operator = (const Transport &);
private:
image_id fImage;
PFN_init_transport fInitTransport;
PFN_exit_transport fExitTransport;
BDataIO *fDataStream;
bool fAbort;
string fLastErrorString;
};
#endif // __TRANSPORT_H
/*
* Transport.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#ifndef __TRANSPORT_H
#define __TRANSPORT_H
#include <image.h>
#include <string>
class BDataIO;
class PrinterData;
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
extern "C" {
typedef BDataIO *(*PFN_init_transport)(BMessage *);
typedef void (*PFN_exit_transport)(void);
}
class TransportException {
private:
string fWhat;
public:
TransportException(const string &what_arg) : fWhat(what_arg) {}
const char *what() const { return fWhat.c_str(); }
};
class Transport {
public:
Transport(const PrinterData *printer_data);
~Transport();
void write(const void *buffer, size_t size) throw(TransportException);
bool check_abort() const;
bool is_print_to_file_canceled() const;
const string &last_error() const;
protected:
void set_last_error(const char *e);
Transport(const Transport &);
Transport &operator = (const Transport &);
private:
image_id fImage;
PFN_init_transport fInitTransport;
PFN_exit_transport fExitTransport;
BDataIO *fDataStream;
bool fAbort;
string fLastErrorString;
};
#endif // __TRANSPORT_H
+222
View File
@@ -0,0 +1,222 @@
/*
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, kUnitPointS);
! 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:
kUnitInch, 72 points/in
kUnitCM, 28.346 points/cm
kUnitPoint, 1 point/point
*/
#ifndef _MARGIN_VIEW_H
#define _MARGIN_VIEW_H
#include <InterfaceKit.h>
#include <Looper.h>
class BTextControl;
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';
const uint32 MARGIN_UNIT_CHANGED = 'mucg';
enum MarginUnit {
kUnitInch = 0,
kUnitCM,
kUnitPoint
};
/**
* Class MarginView
*/
class MarginView : public BBox
{
friend class MarginManager;
public:
MarginView(BRect rect, int32 pageWidth = 0,
int32 pageHeight = 0,
BRect margins = BRect(1, 1, 1, 1), // 1 inch
MarginUnit unit = kUnitInch);
virtual ~MarginView();
virtual void AttachedToWindow();
virtual void Draw(BRect rect);
virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage *msg);
// point.x = width, point.y = height
BPoint PageSize() const;
void SetPageSize(float pageWidth, float pageHeight);
// margin
BRect Margin() const;
// units
MarginUnit Unit() const;
// will cause a recalc and redraw
void UpdateView(uint32 msg);
private:
// all the GUI construction code
void _ConstructGUI();
// utility method
void _AllowOnlyNumbers(BTextControl *textControl,
int32 maxNum);
// performed internally using text fields
void _SetMargin(BRect margin);
// performed internally using the supplied popup
void _SetMarginUnit(MarginUnit unit);
// Calculate the view size for the margins
void _CalculateViewSize(uint32 msg);
private:
BTextControl* fTop;
BTextControl* fBottom;
BTextControl* fLeft;
BTextControl* 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
MarginUnit fMarginUnit;
float fUnitValue;
// the size of the drawing area we have to draw the view in pixels
float fViewHeight;
float fViewWidth;
};
#endif // _MARGIN_VIEW_H
-1
View File
@@ -1,5 +1,4 @@
SubDir HAIKU_TOP src add-ons print ;
SubInclude HAIKU_TOP src add-ons print shared ;
SubInclude HAIKU_TOP src add-ons print drivers ;
SubInclude HAIKU_TOP src add-ons print transports ;
-1
View File
@@ -1,6 +1,5 @@
SubDir HAIKU_TOP src add-ons print drivers ;
SubInclude HAIKU_TOP src add-ons print drivers shared ;
SubInclude HAIKU_TOP src add-ons print drivers canon_lips ;
SubInclude HAIKU_TOP src add-ons print drivers pcl5 ;
SubInclude HAIKU_TOP src add-ons print drivers pcl6 ;
@@ -2,8 +2,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 ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources Canon\ LIPS3\ Compatible : Lips3.rdef ;
@@ -13,8 +12,8 @@ Addon Canon\ LIPS3\ Compatible :
Lips3Cap.cpp
Compress3.cpp
:
be
libprint.a
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
;
@@ -2,8 +2,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 ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources Canon\ LIPS4\ Compatible : Lips4.rdef ;
@@ -12,8 +11,8 @@ Addon Canon\ LIPS4\ Compatible :
Lips4.cpp
Lips4Cap.cpp
:
be
libprint.a
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
;
+3 -4
View File
@@ -2,8 +2,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 ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources PCL5\ Compatible : PCL5.rsrc ;
@@ -12,8 +11,8 @@ Addon PCL5\ Compatible :
PCL5.cpp
PCL5Cap.cpp
:
be
libprint.a
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
;
+3 -4
View File
@@ -2,8 +2,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 ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources PCL6\ Compatible : PCL6.rsrc ;
@@ -16,8 +15,8 @@ Addon PCL6\ Compatible :
PCL6Writer.cpp
Rasterizer.cpp
:
be
libprint.a
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
;
+1 -2
View File
@@ -2,8 +2,7 @@ SubDir HAIKU_TOP src add-ons print drivers pdf source ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src libs pdflib libs pdflib ] ;
AddResources PDF\ Writer :
+3 -4
View File
@@ -2,8 +2,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 ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources PS\ Compatible : PS.rsrc ;
@@ -12,8 +11,8 @@ Addon PS\ Compatible :
PS.cpp
PSCap.cpp
:
be
libprint.a
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
;
+1 -4
View File
@@ -2,10 +2,7 @@ SubDir HAIKU_TOP src add-ons print drivers preview ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers private print utils ] ;
UsePrivateHeaders interface ;
UsePrivateHeaders print ;
AddResources Preview : Preview.rsrc ;
-4
View File
@@ -1,4 +0,0 @@
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 ;
@@ -1,12 +0,0 @@
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
;
-32
View File
@@ -1,32 +0,0 @@
SubDir HAIKU_TOP src add-ons print shared ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders interface print ;
StaticLibrary
libprintutils.a
:
PicturePrinter.cpp
PrintJobReader.cpp
PictureIterator.cpp
PrintTransport.cpp
;
# StaticLibrary
# libprinttransportaddon.a
# :
# PrintTransportAddOn.cpp
# ;
Objects
PrintTransportAddOn.cpp
;
#StaticLibrary
# libprinterdriveraddon.a
# :
# PrinterDriverAddOn.cpp
# ;
@@ -2,17 +2,15 @@ SubDir HAIKU_TOP src add-ons print transports parallel_port ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src add-ons print transports shared ] ;
UsePrivateHeaders interface print ;
Addon Parallel\ Port :
ParallelTransport.cpp
PrintTransportAddOn.o
: be
: be libprintutils.a
;
ObjectReferences <src!add-ons!print!shared>PrintTransportAddOn.o ;
Package haiku-printingkit-cvs :
Parallel\ Port :
boot home config add-ons Print transport ;
@@ -2,17 +2,15 @@ SubDir HAIKU_TOP src add-ons print transports serial_port ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src add-ons print transports shared ] ;
UsePrivateHeaders interface print ;
Addon Serial\ Port :
SerialTransport.cpp
PrintTransportAddOn.o
: be
: be libprintutils.a
;
ObjectReferences <src!add-ons!print!shared>PrintTransportAddOn.o ;
Package haiku-printingkit-cvs :
Serial\ Port :
boot home config add-ons Print transport ;
@@ -2,17 +2,15 @@ SubDir HAIKU_TOP src add-ons print transports usb_port ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src add-ons print transports shared ] ;
UsePrivateHeaders interface print ;
Addon USB\ Port :
USBTransport.cpp
PrintTransportAddOn.o
: be
: be libprintutils.a
;
ObjectReferences <src!add-ons!print!shared>PrintTransportAddOn.o ;
Package haiku-printingkit-cvs :
USB\ Port :
boot home config add-ons Print transport ;
+1
View File
@@ -94,6 +94,7 @@ SubInclude HAIKU_TOP src kits midi ;
SubInclude HAIKU_TOP src kits midi2 ;
SubInclude HAIKU_TOP src kits network ;
SubInclude HAIKU_TOP src kits opengl ;
SubInclude HAIKU_TOP src kits print ;
SubInclude HAIKU_TOP src kits screensaver ;
SubInclude HAIKU_TOP src kits shared ;
SubInclude HAIKU_TOP src kits storage ;
+1 -1
View File
@@ -25,7 +25,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
SetSubDirSupportedPlatforms haiku libbe_test ;
UsePrivateHeaders app input interface shared tracker ;
UsePrivateHeaders app input print interface shared tracker ;
UseLibraryHeaders icon png zlib ;
+20
View File
@@ -0,0 +1,20 @@
SubDir HAIKU_TOP src kits print ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders shared print ;
StaticLibrary libprintutils.a :
BeUtils.cpp
BeUtilsTranslation.cpp
FolderWatcher.cpp
InterfaceUtils.cpp
Jobs.cpp
MarginView.cpp
PrintJobReader.cpp
PicturePrinter.cpp
PrintTransport.cpp
PictureIterator.cpp
PrintTransportAddOn.cpp
Utils.cpp
;
+1
View File
@@ -16,6 +16,7 @@ SubInclude HAIKU_TOP src libs lp_solve ;
SubInclude HAIKU_TOP src libs ncurses ;
SubInclude HAIKU_TOP src libs pdflib ;
SubInclude HAIKU_TOP src libs png ;
SubInclude HAIKU_TOP src libs print ;
SubInclude HAIKU_TOP src libs stdc++ ;
SubInclude HAIKU_TOP src libs termcap ;
SubInclude HAIKU_TOP src libs util ;
+3
View File
@@ -0,0 +1,3 @@
SubDir HAIKU_TOP src libs print ;
SubInclude HAIKU_TOP src libs print libprint ;
@@ -1,110 +1,110 @@
/*
* AboutBox.cpp
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#include <cstdio>
#include <string>
#include <Window.h>
#include <View.h>
#include <Button.h>
#include "AboutBox.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
enum {
kMsgOK = 'AbOK'
};
class AboutBoxView : public BView {
public:
AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright);
virtual void Draw(BRect);
virtual void AttachedToWindow();
private:
string fDriverName;
string fVersion;
string fCopyright;
};
AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright)
: BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
{
fDriverName = driver_name;
fVersion = version;
fCopyright = copyright;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetDrawingMode(B_OP_SELECT);
}
void AboutBoxView::Draw(BRect)
{
SetHighColor(0, 0, 0);
DrawString(fDriverName.c_str(), BPoint(10.0f, 16.0f));
DrawString(" Driver for ");
SetHighColor(0, 0, 0xff);
DrawString("B");
SetHighColor(0xff, 0, 0);
DrawString("e");
SetHighColor(0, 0, 0);
DrawString("OS Version ");
DrawString(fVersion.c_str());
DrawString(fCopyright.c_str(), BPoint(10.0f, 30.0f));
}
void AboutBoxView::AttachedToWindow()
{
BRect rect;
rect.Set(110, 50, 175, 55);
BButton *button = new BButton(rect, "", "OK", new BMessage(kMsgOK));
AddChild(button);
button->MakeDefault(true);
}
class AboutBoxWindow : public BWindow {
public:
AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright);
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
};
AboutBoxWindow::AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright)
: BWindow(frame, "", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
{
char title[256];
sprintf(title, "About %s Driver", driver_name);
SetTitle(title);
AddChild(new AboutBoxView(Bounds(), driver_name, version, copyright));
}
void AboutBoxWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgOK:
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}
}
bool AboutBoxWindow::QuitRequested()
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
AboutBox::AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright)
: BApplication(signature)
{
BRect rect;
rect.Set(100, 80, 400, 170);
AboutBoxWindow *window = new AboutBoxWindow(rect, driver_name, version, copyright);
window->Show();
}
/*
* AboutBox.cpp
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#include <cstdio>
#include <string>
#include <Window.h>
#include <View.h>
#include <Button.h>
#include "AboutBox.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
enum {
kMsgOK = 'AbOK'
};
class AboutBoxView : public BView {
public:
AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright);
virtual void Draw(BRect);
virtual void AttachedToWindow();
private:
string fDriverName;
string fVersion;
string fCopyright;
};
AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright)
: BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
{
fDriverName = driver_name;
fVersion = version;
fCopyright = copyright;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetDrawingMode(B_OP_SELECT);
}
void AboutBoxView::Draw(BRect)
{
SetHighColor(0, 0, 0);
DrawString(fDriverName.c_str(), BPoint(10.0f, 16.0f));
DrawString(" Driver for ");
SetHighColor(0, 0, 0xff);
DrawString("B");
SetHighColor(0xff, 0, 0);
DrawString("e");
SetHighColor(0, 0, 0);
DrawString("OS Version ");
DrawString(fVersion.c_str());
DrawString(fCopyright.c_str(), BPoint(10.0f, 30.0f));
}
void AboutBoxView::AttachedToWindow()
{
BRect rect;
rect.Set(110, 50, 175, 55);
BButton *button = new BButton(rect, "", "OK", new BMessage(kMsgOK));
AddChild(button);
button->MakeDefault(true);
}
class AboutBoxWindow : public BWindow {
public:
AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright);
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
};
AboutBoxWindow::AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright)
: BWindow(frame, "", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
{
char title[256];
sprintf(title, "About %s Driver", driver_name);
SetTitle(title);
AddChild(new AboutBoxView(Bounds(), driver_name, version, copyright));
}
void AboutBoxWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kMsgOK:
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}
}
bool AboutBoxWindow::QuitRequested()
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
AboutBox::AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright)
: BApplication(signature)
{
BRect rect;
rect.Set(100, 80, 400, 170);
AboutBoxWindow *window = new AboutBoxWindow(rect, driver_name, version, copyright);
window->Show();
}
@@ -1,13 +1,9 @@
SubDir HAIKU_TOP src add-ons print drivers shared libprint ;
SubDir HAIKU_TOP src libs print libprint ;
SetSubDirSupportedPlatformsBeOSCompatible ;
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 ] ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
StaticLibrary libprint.a :
AboutBox.cpp
@@ -1,120 +1,120 @@
/*
* Transport.cpp
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#include <FindDirectory.h>
#include <Message.h>
#include <Directory.h>
#include <DataIO.h>
#include <File.h>
#include <Path.h>
#include <image.h>
#include "Transport.h"
#include "PrinterData.h"
#include "DbgMsg.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
Transport::Transport(const PrinterData *printer_data)
: fImage(-1), fInitTransport(0), fExitTransport(0), fDataStream(0), fAbort(false)
{
BPath path;
if (B_OK == find_directory(B_USER_ADDONS_DIRECTORY, &path)) {
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path()));
fImage = load_add_on(path.Path());
}
if (fImage < 0) {
if (B_OK == find_directory(B_BEOS_ADDONS_DIRECTORY, &path)) {
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path()));
fImage = load_add_on(path.Path());
}
}
if (fImage < 0) {
set_last_error("cannot load a transport add-on");
return;
}
DBGMSG(("image id = %d\n", (int)fImage));
get_image_symbol(fImage, "init_transport", B_SYMBOL_TYPE_TEXT, (void **)&fInitTransport);
get_image_symbol(fImage, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **)&fExitTransport);
if (fInitTransport == NULL) {
set_last_error("get_image_symbol failed.");
DBGMSG(("init_transport is NULL\n"));
}
if (fExitTransport == NULL) {
set_last_error("get_image_symbol failed.");
DBGMSG(("exit_transport is NULL\n"));
}
if (fInitTransport) {
string spool_path;
printer_data->getPath(spool_path);
BMessage *msg = new BMessage('TRIN');
msg->AddString("printer_file", spool_path.c_str());
fDataStream = (*fInitTransport)(msg);
delete msg;
if (fDataStream == 0) {
set_last_error("init_transport failed.");
}
}
}
Transport::~Transport()
{
if (fExitTransport) {
(*fExitTransport)();
}
if (fImage >= 0) {
unload_add_on(fImage);
}
}
bool Transport::check_abort() const
{
return fDataStream == 0;
}
const string &Transport::last_error() const
{
return fLastErrorString;
}
bool Transport::is_print_to_file_canceled() const
{
// The BeOS "Print To File" transport add-on returns a non-NULL BDataIO *
// even after user filepanel cancellation!
BFile* file = dynamic_cast<BFile*>(fDataStream);
return file != NULL && file->InitCheck() != B_OK;
}
void Transport::set_last_error(const char *e)
{
fLastErrorString = e;
fAbort = true;
}
void Transport::write(const void *buffer, size_t size) throw(TransportException)
{
if (fDataStream) {
if (size == (size_t)fDataStream->Write(buffer, size)) {
return;
}
set_last_error("BDataIO::Write failed.");
}
throw TransportException(last_error());
}
/*
* Transport.cpp
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/
#include <FindDirectory.h>
#include <Message.h>
#include <Directory.h>
#include <DataIO.h>
#include <File.h>
#include <Path.h>
#include <image.h>
#include "Transport.h"
#include "PrinterData.h"
#include "DbgMsg.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;
#else
#define std
#endif
Transport::Transport(const PrinterData *printer_data)
: fImage(-1), fInitTransport(0), fExitTransport(0), fDataStream(0), fAbort(false)
{
BPath path;
if (B_OK == find_directory(B_USER_ADDONS_DIRECTORY, &path)) {
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path()));
fImage = load_add_on(path.Path());
}
if (fImage < 0) {
if (B_OK == find_directory(B_BEOS_ADDONS_DIRECTORY, &path)) {
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path()));
fImage = load_add_on(path.Path());
}
}
if (fImage < 0) {
set_last_error("cannot load a transport add-on");
return;
}
DBGMSG(("image id = %d\n", (int)fImage));
get_image_symbol(fImage, "init_transport", B_SYMBOL_TYPE_TEXT, (void **)&fInitTransport);
get_image_symbol(fImage, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **)&fExitTransport);
if (fInitTransport == NULL) {
set_last_error("get_image_symbol failed.");
DBGMSG(("init_transport is NULL\n"));
}
if (fExitTransport == NULL) {
set_last_error("get_image_symbol failed.");
DBGMSG(("exit_transport is NULL\n"));
}
if (fInitTransport) {
string spool_path;
printer_data->getPath(spool_path);
BMessage *msg = new BMessage('TRIN');
msg->AddString("printer_file", spool_path.c_str());
fDataStream = (*fInitTransport)(msg);
delete msg;
if (fDataStream == 0) {
set_last_error("init_transport failed.");
}
}
}
Transport::~Transport()
{
if (fExitTransport) {
(*fExitTransport)();
}
if (fImage >= 0) {
unload_add_on(fImage);
}
}
bool Transport::check_abort() const
{
return fDataStream == 0;
}
const string &Transport::last_error() const
{
return fLastErrorString;
}
bool Transport::is_print_to_file_canceled() const
{
// The BeOS "Print To File" transport add-on returns a non-NULL BDataIO *
// even after user filepanel cancellation!
BFile* file = dynamic_cast<BFile*>(fDataStream);
return file != NULL && file->InitCheck() != B_OK;
}
void Transport::set_last_error(const char *e)
{
fLastErrorString = e;
fAbort = true;
}
void Transport::write(const void *buffer, size_t size) throw(TransportException)
{
if (fDataStream) {
if (size == (size_t)fDataStream->Write(buffer, size)) {
return;
}
set_last_error("BDataIO::Write failed.");
}
throw TransportException(last_error());
}
@@ -1,90 +1,90 @@
/*
* make_pattern.cpp
* Copyright 2000 Y.Takagi All Rights Reserved.
*/
#include <iostream>
#include <iomanip>
using namespace std;
#define MAX_HORTZ 4
#define MAX_VERT 4
#define MAX_ELEMENT (MAX_HORTZ * MAX_VERT)
#include "original_dither_pattern.h"
void create_index_table(const unsigned char *p1, unsigned char *p2)
{
for (int i = 0 ; i < MAX_ELEMENT ; i++) {
p2[*p1] = i;
p1++;
}
}
inline int index2horz(int index)
{
return index % MAX_HORTZ;
}
inline int index2vert(int index)
{
return index / MAX_HORTZ;
}
void create_pattern16x16(const unsigned char *pattern4x4, unsigned char *pattern16x16)
{
unsigned char value2index[MAX_ELEMENT];
create_index_table(pattern4x4, value2index);
for (int i = 0 ; i < MAX_ELEMENT ; i++) {
int index = value2index[i];
int h = index2horz(index);
int v = index2vert(index);
for (int j = 0 ; j < MAX_ELEMENT ; j++) {
int index2 = value2index[j];
int h2 = index2horz(index2) * 4 + h;
int v2 = index2vert(index2) * 4 + v;
pattern16x16[h2 + v2 * MAX_ELEMENT] = j + i * MAX_ELEMENT;
}
}
}
void print_pattern(ostream &os, const char *name, const unsigned char *pattern)
{
os << "const unsigned char " << name << "[] = {" << '\n' << '\t';
for (int i = 0 ; i < 256 ; i++) {
os << setw(3) << (int)pattern[i];
if (i == MAX_ELEMENT * MAX_ELEMENT - 1) {
os << '\n';
} else {
os << ',';
if (i % MAX_ELEMENT == MAX_ELEMENT - 1) {
os << '\n' << '\t';
}
}
}
os << "};" << '\n';
}
int main()
{
unsigned char pattern16x16_type1[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type1, pattern16x16_type1);
print_pattern(cout, "pattern16x16_type1", pattern16x16_type1);
cout << endl;
unsigned char pattern16x16_type2[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type2, pattern16x16_type2);
print_pattern(cout, "pattern16x16_type2", pattern16x16_type2);
cout << endl;
unsigned char pattern16x16_type3[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type3, pattern16x16_type3);
print_pattern(cout, "pattern16x16_type3", pattern16x16_type3);
cout << endl;
return 0;
}
/*
* make_pattern.cpp
* Copyright 2000 Y.Takagi All Rights Reserved.
*/
#include <iostream>
#include <iomanip>
using namespace std;
#define MAX_HORTZ 4
#define MAX_VERT 4
#define MAX_ELEMENT (MAX_HORTZ * MAX_VERT)
#include "original_dither_pattern.h"
void create_index_table(const unsigned char *p1, unsigned char *p2)
{
for (int i = 0 ; i < MAX_ELEMENT ; i++) {
p2[*p1] = i;
p1++;
}
}
inline int index2horz(int index)
{
return index % MAX_HORTZ;
}
inline int index2vert(int index)
{
return index / MAX_HORTZ;
}
void create_pattern16x16(const unsigned char *pattern4x4, unsigned char *pattern16x16)
{
unsigned char value2index[MAX_ELEMENT];
create_index_table(pattern4x4, value2index);
for (int i = 0 ; i < MAX_ELEMENT ; i++) {
int index = value2index[i];
int h = index2horz(index);
int v = index2vert(index);
for (int j = 0 ; j < MAX_ELEMENT ; j++) {
int index2 = value2index[j];
int h2 = index2horz(index2) * 4 + h;
int v2 = index2vert(index2) * 4 + v;
pattern16x16[h2 + v2 * MAX_ELEMENT] = j + i * MAX_ELEMENT;
}
}
}
void print_pattern(ostream &os, const char *name, const unsigned char *pattern)
{
os << "const unsigned char " << name << "[] = {" << '\n' << '\t';
for (int i = 0 ; i < 256 ; i++) {
os << setw(3) << (int)pattern[i];
if (i == MAX_ELEMENT * MAX_ELEMENT - 1) {
os << '\n';
} else {
os << ',';
if (i % MAX_ELEMENT == MAX_ELEMENT - 1) {
os << '\n' << '\t';
}
}
}
os << "};" << '\n';
}
int main()
{
unsigned char pattern16x16_type1[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type1, pattern16x16_type1);
print_pattern(cout, "pattern16x16_type1", pattern16x16_type1);
cout << endl;
unsigned char pattern16x16_type2[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type2, pattern16x16_type2);
print_pattern(cout, "pattern16x16_type2", pattern16x16_type2);
cout << endl;
unsigned char pattern16x16_type3[MAX_ELEMENT * MAX_ELEMENT];
create_pattern16x16(pattern4x4_type3, pattern16x16_type3);
print_pattern(cout, "pattern16x16_type3", pattern16x16_type3);
cout << endl;
return 0;
}
@@ -1,24 +1,24 @@
/*
* These patterns are defined referring to Japanese Monthly C Magazine (May 2000 Vol.12 No.5).
*/
const unsigned char pattern4x4_type1[MAX_ELEMENT] = {
0, 8, 2, 10,
12, 4, 14, 6,
3, 11, 1, 9,
15, 7, 13, 5
};
const unsigned char pattern4x4_type2[MAX_ELEMENT] = {
9, 8, 7, 6,
10, 1, 0, 5,
11, 2, 3, 4,
12, 13, 14, 15
};
const unsigned char pattern4x4_type3[MAX_ELEMENT] = {
0, 2, 14, 12,
8, 10, 5, 7,
15, 13, 1, 3,
4, 6, 9, 11
};
/*
* These patterns are defined referring to Japanese Monthly C Magazine (May 2000 Vol.12 No.5).
*/
const unsigned char pattern4x4_type1[MAX_ELEMENT] = {
0, 8, 2, 10,
12, 4, 14, 6,
3, 11, 1, 9,
15, 7, 13, 5
};
const unsigned char pattern4x4_type2[MAX_ELEMENT] = {
9, 8, 7, 6,
10, 1, 0, 5,
11, 2, 3, 4,
12, 13, 14, 15
};
const unsigned char pattern4x4_type3[MAX_ELEMENT] = {
0, 2, 14, 12,
8, 10, 5, 7,
15, 13, 1, 3,
4, 6, 9, 11
};
+1 -1
View File
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src preferences print ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders interface shared print ;
UsePrivateHeaders shared print ;
Preference Printers :
AddPrinterDialog.cpp
+7 -18
View File
@@ -2,22 +2,13 @@ SubDir HAIKU_TOP src servers print ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SubInclude HAIKU_TOP src servers print shared ;
UsePrivateHeaders shared print ;
SubDir HAIKU_TOP src servers print ;
UsePrivateHeaders shared interface print ;
UsePrivateHeaders print ;
AddResources
print_server
:
AddResources print_server :
print_server.rdef
;
;
Server
print_server
:
Server print_server :
PrintServerApp.cpp
PrintServerApp.R5.cpp
PrintServerApp.Scripting.cpp
@@ -28,16 +19,14 @@ Server
ResourceManager.cpp
Settings.cpp
ConfigWindow.cpp
;
;
LinkAgainst
print_server
:
LinkAgainst print_server :
be
root
translation
libprintutils.a
;
;
Package haiku-printingkit-cvs :
print_server :
-14
View File
@@ -1,14 +0,0 @@
SubDir HAIKU_TOP src servers print shared ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders shared interface print ;
StaticLibrary
libprintutils.a
:
BeUtils.cpp
BeUtilsTranslation.cpp
FolderWatcher.cpp
Jobs.cpp
;