* merge parts of libprint and libprintutils to make both indepentend

* adjust all drivers to take that into account
* fix UpdateText() signature in JSDSlider to avoid warning



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26648 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2008-07-26 22:36:01 +00:00
parent 0f104a754b
commit 0ca6b749f4
48 changed files with 198 additions and 422 deletions

View File

@ -31,8 +31,21 @@ THE SOFTWARE.
#define _INTERFACE_UTILS_H
#include <InterfaceKit.h>
#include <MessageFilter.h>
class EscapeMessageFilter : public BMessageFilter
{
private:
BWindow *fWindow;
int32 fWhat;
public:
EscapeMessageFilter(BWindow *window, int32 what);
filter_result Filter(BMessage *msg, BHandler **target);
};
// --------------------------------------------------
class HWindow : public BWindow
{
protected:
@ -49,7 +62,7 @@ public:
virtual const char* AboutText() const { return NULL; }
};
// --------------------------------------------------
class BlockingWindow : public HWindow
{
public:

View File

@ -17,15 +17,15 @@
class JSDSlider : public BSlider
{
public:
JSDSlider(BRect frame, const char* name, const char *label, BMessage *msg,
int32 min, int32 max, thumb_style t);
JSDSlider(BRect frame, const char* name, const char *label,
BMessage *msg, int32 min, int32 max, thumb_style t);
virtual ~JSDSlider();
virtual const char* UpdateText() const;
~JSDSlider();
char* UpdateText() const;
private:
BString* fResult;
mutable BString fResult;
};
#endif

View File

@ -30,8 +30,8 @@ THE SOFTWARE.
*/
#ifndef _UTILS_H
#define _UTILS_H
#ifndef _PRINT_UTILS_H_
#define _PRINT_UTILS_H_
#include <List.h>
@ -45,29 +45,21 @@ class BMessage;
class BWindow;
#define BEGINS_CHAR(byte) ((byte & 0xc0) != 0x80)
BRect ScaleRect(const BRect& rect, float scale);
// set or replace a value in a BMessage
void SetBool(BMessage* msg, const char* name, bool value);
void SetFloat(BMessage* msg, const char* name, float value);
void SetInt32(BMessage* msg, const char* name, int32 value);
void SetString(BMessage* msg, const char* name, const char* value);
void SetRect(BMessage* msg, const char* name, const BRect& rect);
void SetString(BMessage* msg, const char* name, const BString& 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)
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL,
const char* includeList[] = NULL, bool overwrite = true);
template <class T>
@ -139,4 +131,4 @@ void TList<T>::SortItems(int (*comp)(const T**, const T**)) {
fList.SortItems(sort);
}
#endif
#endif // _PRINT_UTILS_H_

View File

@ -90,8 +90,6 @@ 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, 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!
@ -99,7 +97,4 @@ BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP);
BPicture *BitmapToPicture(BView* view, BBitmap *bitmap);
BPicture *BitmapToGrayedPicture(BView* view, BBitmap *bitmap);
// scalar multiplication
BRect ScaleRect(BRect rect, float scale);
#endif

View File

@ -1,222 +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, 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

View File

@ -11,11 +11,7 @@ Addon Canon\ LIPS3\ Compatible :
Lips3.cpp
Lips3Cap.cpp
Compress3.cpp
:
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
: be libprint.a $(TARGET_LIBSTDC++)
;
Package haiku-printingkit-cvs :

View File

@ -10,11 +10,7 @@ Addon Canon\ LIPS4\ Compatible :
Lips4Entry.cpp
Lips4.cpp
Lips4Cap.cpp
:
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
: be libprint.a $(TARGET_LIBSTDC++)
;
Package haiku-printingkit-cvs :

View File

@ -10,11 +10,7 @@ Addon PCL5\ Compatible :
PCL5Entry.cpp
PCL5.cpp
PCL5Cap.cpp
:
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
: be libprint.a $(TARGET_LIBSTDC++)
;
Package haiku-printingkit-cvs :

View File

@ -14,11 +14,7 @@ Addon PCL6\ Compatible :
PCL6Rasterizer.cpp
PCL6Writer.cpp
Rasterizer.cpp
:
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
: be libprint.a $(TARGET_LIBSTDC++)
;
Package haiku-printingkit-cvs :

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
*/
#include "AdvancedSettingsWindow.h"
#include "Utils.h"
#include "PrintUtils.h"
#include <Box.h>

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#ifndef _CACHE_H
#define _CACHE_H
#include "Utils.h"
#include "PrintUtils.h"
class CacheItem;

View File

@ -40,7 +40,7 @@ THE SOFTWARE.
#include <Path.h>
#include <String.h>
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
#define HAVE_FULLVERSION_PDF_LIB 0

View File

@ -35,7 +35,7 @@ THE SOFTWARE.
#include <Archivable.h>
#include <String.h>
#include <List.h>
#include "Utils.h"
#include "PrintUtils.h"
enum font_encoding
{

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
#include <FindDirectory.h>
#include <Path.h>
#include <String.h>
#include "Utils.h"
#include "PrintUtils.h"
#include "Fonts.h"
#define USE_CLV 0

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
#include <Bitmap.h>
#include "pdflib.h"
#include "Utils.h"
#include "PrintUtils.h"
#include "Cache.h"
class Image;

View File

@ -35,7 +35,7 @@ THE SOFTWARE.
#include <String.h>
#include "pdflib.h"
#include "Utils.h"
#include "PrintUtils.h"
#include "Cache.h"
extern const char* kTemporaryPath;

View File

@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons print drivers pdf source ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src libs pdflib libs pdflib ] ;
AddResources PDF\ Writer :
@ -45,7 +46,8 @@ Addon PDF\ Writer :
be
textencoding
translation
libpdf.a
libpdf.a
libprint.a
libprintutils.a
;

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include <SupportKit.h>
#include <stdlib.h>
#include "BeUtils.h"
#include "PrintUtils.h"
#include "PrinterDriver.h"
#include "JobSetupWindow.h"

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
#include <InterfaceKit.h>
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
class JobSetupWindow : public HWindow
{

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include <String.h>
#include <Font.h>
#include <Point.h>
#include "Utils.h"
#include "PrintUtils.h"
#include "PDFSystem.h"
class PDFSystem;

View File

@ -43,7 +43,7 @@ THE SOFTWARE.
#include "PictureIterator.h"
#include "Fonts.h"
#include "SubPath.h"
#include "Utils.h"
#include "PrintUtils.h"
#include "Link.h"
#include "ImageCache.h"
#include "PDFSystem.h"

View File

@ -40,7 +40,7 @@ THE SOFTWARE.
#include "MarginView.h"
#include "PrinterDriver.h"
#include "pdflib.h" // for pageFormat constants
#include "Utils.h"
#include "PrintUtils.h"
#include <Box.h>

View File

@ -37,6 +37,8 @@ THE SOFTWARE.
#include "PrintTransport.h"
class BNode;
#ifndef ROUND_UP
#define ROUND_UP(x, y) (((x) + (y) - 1) & ~((y) - 1))
#endif

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include <fs_attr.h>
#include "BeUtils.h"
#include "PrintUtils.h"
#include "PrinterPrefs.h"

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
#include <InterfaceKit.h>
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
class PrinterSetupWindow : public HWindow
{

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include <stdio.h>
#include <String.h>
#include <Locker.h>
#include "Utils.h"
#include "PrintUtils.h"
enum kind {

View File

@ -37,7 +37,7 @@ THE SOFTWARE.
//class PrinterDriver;
#include "PrinterDriver.h"
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
class StatusWindow : public HWindow
{

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include <List.h>
#include "Link.h"
#include "RegExp.h"
#include "Utils.h"
#include "PrintUtils.h"
class MatchResult;
class Pattern;

View File

@ -10,11 +10,7 @@ Addon PS\ Compatible :
PSEntry.cpp
PS.cpp
PSCap.cpp
:
be
libprint.a
libprintutils.a
$(TARGET_LIBSTDC++)
: be libprint.a $(TARGET_LIBSTDC++)
;
Package haiku-printingkit-cvs :

View File

@ -2,7 +2,7 @@ SubDir HAIKU_TOP src add-ons print drivers preview ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources Preview : Preview.rsrc ;
@ -13,10 +13,7 @@ Addon Preview :
Preview.cpp
PrinterDriver.cpp
PreviewDriver.cpp
:
be
root
libprintutils.a
: be libprint.a
;
Package haiku-printingkit-cvs :

View File

@ -14,7 +14,7 @@
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
#include <String.h>

View File

@ -10,11 +10,10 @@
* julun <host.haiku@gmx.de>
*/
#include "BeUtils.h"
#include "MarginView.h"
#include "PrinterDriver.h"
#include "PageSetupWindow.h"
#include "PrintUtils.h"
#include <stdlib.h>

View File

@ -15,7 +15,7 @@
#include "InterfaceUtils.h"
#include "Utils.h"
#include "PrintUtils.h"
#include <String.h>

View File

@ -8,10 +8,8 @@
* julun <host.haiku@gmx.de>
*/
#include "BeUtils.h"
#include "Utils.h"
#include "Preview.h"
#include "PrintUtils.h"
#include <stdlib.h>

View File

@ -93,56 +93,3 @@ bool MimeTypeForSender(BMessage* sender, BString& mime) {
}
return false;
}
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;
}
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[], const char* includeList[], bool overwrite) {
if (to == from) return;
#ifndef B_BEOS_VERSION_DANO
char* name;
#else
const char* name;
#endif
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) {
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);
}
}
}
}
}
BRect ScaleRect(BRect rect, float scale) {
rect.left *= scale;
rect.right *= scale;
rect.top *= scale;
rect.bottom *= scale;
return rect;
}

View File

@ -8,13 +8,9 @@ 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
;

View File

@ -30,7 +30,28 @@ THE SOFTWARE.
#include <string.h>
#include <Debug.h>
#include "InterfaceUtils.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;
}
// Implementation of HWindow

View File

@ -9,42 +9,42 @@
#include "JSDSlider.h"
#include <Window.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
JSDSlider :: JSDSlider(BRect frame, const char* name, const char *label,
BMessage *msg, int32 min, int32 max, thumb_style t)
: BSlider(frame, name, label, msg, min, max, t)
{
fResult = new BString();
}
JSDSlider :: ~JSDSlider()
{
delete fResult;
}
char* JSDSlider :: UpdateText() const
JSDSlider::JSDSlider(BRect frame, const char* name, const char *label,
BMessage *msg, int32 min, int32 max, thumb_style t)
: BSlider(frame, name, label, msg, min, max, t)
{
// When the slider's Draw method is called, this method
// will also be called. If its return value is non-NULL,
// then it will be drawn with the rest of the slider
}
JSDSlider::~JSDSlider()
{
}
const char*
JSDSlider::UpdateText() const
{
// When the slider's Draw method is called, this method will also be called.
// If its return value is non-NULL, then it will be drawn with the rest of
// the slider
static char string[64];
string[0] = 0;
if (!strcmp("gamma", Name()) ) {
if (!strcmp("gamma", Name())) {
float gamma;
gamma = exp((Value() * log(2.0) * 0.01) );
sprintf(string, " %.2f", gamma);
} else if (!strcmp("inkDensity", Name()) ) {
gamma = exp((Value() * log(2.0) * 0.01) );
sprintf(string, " %.2f", gamma);
} else if (!strcmp("inkDensity", Name()) ) {
float density = Value();
density = (density / 127.0) * 100.0;
sprintf(string," %.0f%%", density);
density = (density / 127.0) * 100.0;
sprintf(string," %.0f%%", density);
}
*fResult = string;
return (char *)fResult->String();
}
fResult.SetTo(string);
return fResult.String();
}

View File

@ -2,7 +2,6 @@ SubDir HAIKU_TOP src libs print libprint ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
StaticLibrary libprint.a :
@ -13,9 +12,11 @@ StaticLibrary libprint.a :
GraphicsDriver.cpp
Halftone.cpp
HalftoneView.cpp
InterfaceUtils.cpp
JSDSlider.cpp
JobData.cpp
JobSetupDlg.cpp
MarginView.cpp
PackBits.cpp
PageSetupDlg.cpp
PagesView.cpp
@ -24,6 +25,8 @@ StaticLibrary libprint.a :
PrinterDriver.cpp
PrinterCap.cpp
PrintProcess.cpp
PrintJobReader.cpp
PrintUtils.cpp
SpoolMetaData.cpp
StatusWindow.cpp
Transport.cpp

View File

@ -30,13 +30,15 @@
#include <TextControl.h>
#include <View.h>
#include "BeUtils.h"
#include "DbgMsg.h"
#include "JobData.h"
#include "MarginView.h"
#include "PageSetupDlg.h"
#include "PrinterData.h"
#include "PrinterCap.h"
#include "PrintUtils.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std;

View File

@ -11,11 +11,11 @@
#include <Debug.h>
#include <String.h>
#include "BeUtils.h"
#include "Utils.h"
#include "GraphicsDriver.h"
#include "Preview.h"
#include "PrintUtils.h"
// Implementation of PreviewPage
PreviewPage::PreviewPage(int32 page, PrintJobPage* pjp)

View File

@ -30,13 +30,27 @@ THE SOFTWARE.
*/
#include "Utils.h"
#include "PrintUtils.h"
#include <Message.h>
#include <Window.h>
BRect
ScaleRect(const BRect& rect, float scale)
{
BRect scaleRect(rect);
scaleRect.left *= scale;
scaleRect.right *= scale;
scaleRect.top *= scale;
scaleRect.bottom *= scale;
return scaleRect;
}
void
SetBool(BMessage* msg, const char* name, bool value)
{
@ -99,25 +113,58 @@ SetString(BMessage* msg, const char* name, const BString& value)
}
// #pragma mark -- EscapeMessageFilter
EscapeMessageFilter::EscapeMessageFilter(BWindow *window, int32 what)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, '_KYD')
, fWindow(window),
fWhat(what)
static
bool InList(const char* list[], const char* name)
{
}
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;
for (int i = 0; list[i] != NULL; ++i) {
if (strcmp(list[i], name) == 0)
return true;
}
return false;
}
void
AddFields(BMessage* to, const BMessage* from, const char* excludeList[],
const char* includeList[], bool overwrite)
{
if (to == from)
return;
#ifndef B_BEOS_VERSION_DANO
char* name;
#else
const char* name;
#endif
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;
ssize_t size;
const void* data;
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) {
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);
}
}
}
}
return B_DISPATCH_MESSAGE;
}

View File

@ -8,12 +8,13 @@
#include <fs_attr.h> // for attr_info
#include <File.h>
#include <FindDirectory.h>
#include <Message.h>
#include <Node.h>
#include <Path.h>
#include <String.h>
#include <memory> // for auto_ptr
#include "BeUtils.h"
#include "AboutBox.h"
#include "AddPrinterDlg.h"
#include "DbgMsg.h"
@ -23,6 +24,7 @@
#include "PrinterData.h"
#include "UIDriver.h"
#include "Preview.h"
#include "PrintUtils.h"
// Implementation of PrinterDriver

View File

@ -10,7 +10,7 @@
#include "Printer.h"
#include "PrintServerApp.h"
#include "ConfigWindow.h"
#include "BeUtils.h"
#include "PrintUtils.h"
// posix
#include <limits.h>

View File

@ -3,6 +3,7 @@ SubDir HAIKU_TOP src servers print ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders shared print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
AddResources print_server :
print_server.rdef
@ -25,6 +26,7 @@ LinkAgainst print_server :
be
root
translation
libprint.a
libprintutils.a
;