Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37376 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,17 +6,21 @@
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "FilterIO.h"
|
||||
|
||||
#include <String.h>
|
||||
#include <image.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <image.h>
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
FilterIO::FilterIO(const BString& cmdline)
|
||||
: BDataIO()
|
||||
:
|
||||
BDataIO()
|
||||
{
|
||||
BString cmd(cmdline);
|
||||
const char* argv[4];
|
||||
@@ -35,7 +39,8 @@ FilterIO::FilterIO(const BString& cmdline)
|
||||
|
||||
|
||||
FilterIO::FilterIO(int argc, const char **argv, const char **envp)
|
||||
: BDataIO()
|
||||
:
|
||||
BDataIO()
|
||||
{
|
||||
InitData(argc, argv, envp);
|
||||
}
|
||||
@@ -44,9 +49,7 @@ FilterIO::FilterIO(int argc, const char **argv, const char **envp)
|
||||
status_t
|
||||
FilterIO::InitData(int argc, const char** argv, const char** envp)
|
||||
{
|
||||
fStdIn =
|
||||
fStdOut =
|
||||
fStdErr = -1;
|
||||
fStdIn = fStdOut = fStdErr = -1;
|
||||
fInitErr = B_OK;
|
||||
|
||||
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr, envp);
|
||||
@@ -84,7 +87,8 @@ FilterIO::Write(const void *buffer, size_t size)
|
||||
|
||||
|
||||
thread_id
|
||||
FilterIO::PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp)
|
||||
FilterIO::PipeCommand(int argc, const char** argv, int& in, int& out, int& err,
|
||||
const char** envp)
|
||||
{
|
||||
// This function written by Peter Folk <[email protected]>
|
||||
// and published in the BeDevTalk FAQ
|
||||
@@ -100,7 +104,7 @@ FilterIO::PipeCommand(int argc, const char **argv, int &in, int &out, int &err,
|
||||
|
||||
int filedes[2];
|
||||
|
||||
/* Create new pipe FDs as stdin, stdout, stderr */
|
||||
// Create new pipe FDs as stdin, stdout, stderr
|
||||
pipe(filedes); dup2(filedes[0], 0); close(filedes[0]);
|
||||
in = filedes[1]; // Write to in, appears on cmd's stdin
|
||||
pipe(filedes); dup2(filedes[1], 1); close(filedes[1]);
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
* Authors:
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef FILTERIO_H
|
||||
#define FILTERIO_H
|
||||
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
class BString;
|
||||
|
||||
|
||||
class FilterIO : public BDataIO
|
||||
{
|
||||
public:
|
||||
FilterIO(int argc, const char **argv, const char **envp = NULL);
|
||||
FilterIO(int argc, const char** argv,
|
||||
const char** envp = NULL);
|
||||
FilterIO(const BString& cmdline);
|
||||
~FilterIO();
|
||||
|
||||
@@ -33,8 +36,10 @@ private:
|
||||
thread_id fThreadId;
|
||||
status_t fInitErr;
|
||||
|
||||
status_t InitData(int argc, const char **argv, const char **envp = NULL);
|
||||
thread_id PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp = NULL);
|
||||
status_t InitData(int argc, const char** argv,
|
||||
const char** envp = NULL);
|
||||
thread_id PipeCommand(int argc, const char** argv, int& in,
|
||||
int& out, int& err, const char** envp = NULL);
|
||||
};
|
||||
|
||||
#endif /* FILTERIO_H */
|
||||
#endif // FILTERIO_H
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "PPDParser.h"
|
||||
|
||||
#include <Path.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
PPDParser::PPDParser(BFile& file)
|
||||
@@ -73,7 +74,8 @@ PPDParser::GetParameter(const BString& param)
|
||||
// Found our parameter?
|
||||
if (line.Compare(pattern, pattern.Length()) == 0) {
|
||||
// Copy result
|
||||
line.CopyInto(result, pattern.Length(), line.Length() - pattern.Length()).Trim();
|
||||
line.CopyInto(result, pattern.Length(),
|
||||
line.Length() - pattern.Length()).Trim();
|
||||
// If result is quoted, remove quotes
|
||||
if (result[0] == '"') {
|
||||
result.Truncate(result.Length() -1);
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#ifndef PPDPARSER_H
|
||||
#define PPDPARSER_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class BPath;
|
||||
class BFile;
|
||||
class BDirectory;
|
||||
|
||||
|
||||
class PPDParser
|
||||
{
|
||||
public:
|
||||
@@ -21,6 +24,7 @@ public:
|
||||
}
|
||||
|
||||
BString GetParameter(const BString& param);
|
||||
|
||||
private:
|
||||
status_t InitData(BFile& file);
|
||||
|
||||
@@ -28,4 +32,4 @@ private:
|
||||
status_t fInitErr;
|
||||
};
|
||||
|
||||
#endif /* PPDPARSER_H */
|
||||
#endif // PPDPARSER_H
|
||||
|
||||
@@ -5,26 +5,29 @@
|
||||
* Copyright 2010 Ithamar Adema.
|
||||
*/
|
||||
|
||||
|
||||
#include "PS.h"
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "PS.h"
|
||||
#include "UIDriver.h"
|
||||
|
||||
#include "DbgMsg.h"
|
||||
#include "FilterIO.h"
|
||||
#include "Halftone.h"
|
||||
#include "JobData.h"
|
||||
#include "PackBits.h"
|
||||
#include "PPDParser.h"
|
||||
#include "PrinterData.h"
|
||||
#include "PSCap.h"
|
||||
#include "PackBits.h"
|
||||
#include "Halftone.h"
|
||||
#include "ValidRect.h"
|
||||
#include "DbgMsg.h"
|
||||
#include "PSData.h"
|
||||
#include "FilterIO.h"
|
||||
#include "PPDParser.h"
|
||||
|
||||
#include "UIDriver.h"
|
||||
#include "ValidRect.h"
|
||||
|
||||
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
|
||||
using namespace std;
|
||||
@@ -33,8 +36,10 @@ using namespace std;
|
||||
#endif
|
||||
|
||||
|
||||
PSDriver::PSDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
|
||||
: GraphicsDriver(msg, printer_data, printer_cap)
|
||||
PSDriver::PSDriver(BMessage* msg, PrinterData* printer_data,
|
||||
const PrinterCap* printer_cap)
|
||||
:
|
||||
GraphicsDriver(msg, printer_data, printer_cap)
|
||||
{
|
||||
fPrintedPages = 0;
|
||||
fHalftone = NULL;
|
||||
@@ -113,7 +118,9 @@ PSDriver::startDoc()
|
||||
StartFilterIfNeeded();
|
||||
|
||||
jobStart();
|
||||
fHalftone = new Halftone(getJobData()->getSurfaceType(), getJobData()->getGamma(), getJobData()->getInkDensity(), getJobData()->getDitherType());
|
||||
fHalftone = new Halftone(getJobData()->getSurfaceType(),
|
||||
getJobData()->getGamma(), getJobData()->getInkDensity(),
|
||||
getJobData()->getDitherType());
|
||||
return true;
|
||||
}
|
||||
catch (TransportException& err) {
|
||||
@@ -159,7 +166,8 @@ PSDriver::setupCTM()
|
||||
if (getJobData()->getOrientation() == JobData::kPortrait) {
|
||||
// move origin from bottom left to top left
|
||||
// and set margin
|
||||
writePSString("%f %f translate\n", leftMargin, getJobData()->getPaperRect().Height()-topMargin);
|
||||
writePSString("%f %f translate\n", leftMargin,
|
||||
getJobData()->getPaperRect().Height()-topMargin);
|
||||
} else {
|
||||
// landscape:
|
||||
// move origin from bottom left to margin top and left
|
||||
@@ -169,7 +177,8 @@ PSDriver::setupCTM()
|
||||
}
|
||||
// y values increase from top to bottom
|
||||
// units of measure is dpi
|
||||
writePSString("72 %d div 72 -%d div scale\n", getJobData()->getXres(), getJobData()->getYres());
|
||||
writePSString("72 %d div 72 -%d div scale\n", getJobData()->getXres(),
|
||||
getJobData()->getYres());
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +247,8 @@ PSDriver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
|
||||
bool color = getJobData()->getColor() == JobData::kColor;
|
||||
int width = rc.right - rc.left + 1;
|
||||
int widthByte = (width + 7) / 8; /* byte boundary */
|
||||
int widthByte = (width + 7) / 8;
|
||||
// byte boundary
|
||||
int height = rc.bottom - rc.top + 1;
|
||||
int in_size = color ? width : widthByte;
|
||||
int out_size = color ? width * 6: widthByte * 2;
|
||||
@@ -249,9 +259,10 @@ PSDriver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
DBGMSG(("height = %d\n", height));
|
||||
DBGMSG(("out_size = %d\n", out_size));
|
||||
DBGMSG(("delta = %d\n", delta));
|
||||
DBGMSG(("renderobj->get_pixel_depth() = %d\n", fHalftone->getPixelDepth()));
|
||||
DBGMSG(("renderobj->get_pixel_depth() = %d\n",
|
||||
fHalftone->getPixelDepth()));
|
||||
|
||||
uchar *ptr = (uchar *)bitmap->Bits()
|
||||
uchar* ptr = static_cast<uchar*>(bitmap->Bits())
|
||||
+ rc.top * delta
|
||||
+ (rc.left * fHalftone->getPixelDepth()) / 8;
|
||||
|
||||
@@ -259,8 +270,10 @@ PSDriver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
int compressed_size;
|
||||
const uchar* buffer;
|
||||
|
||||
uchar *in_buffer = new uchar[in_size]; // gray values
|
||||
uchar *out_buffer = new uchar[out_size]; // gray values in hexadecimal
|
||||
uchar* in_buffer = new uchar[in_size];
|
||||
// gray values
|
||||
uchar* out_buffer = new uchar[out_size];
|
||||
// gray values in hexadecimal
|
||||
|
||||
auto_ptr<uchar> _in_buffer(in_buffer);
|
||||
auto_ptr<uchar> _out_buffer(out_buffer);
|
||||
@@ -313,17 +326,14 @@ PSDriver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
|
||||
endRasterGraphics();
|
||||
|
||||
} else {
|
||||
} else
|
||||
DBGMSG(("band bitmap is clean.\n"));
|
||||
}
|
||||
|
||||
if (y >= page_height) {
|
||||
offset->x = -1.0;
|
||||
offset->y = -1.0;
|
||||
} else {
|
||||
} else
|
||||
offset->y += height;
|
||||
}
|
||||
|
||||
|
||||
DBGMSG(("< nextBand\n"));
|
||||
return true;
|
||||
@@ -342,10 +352,15 @@ PSDriver::jobStart()
|
||||
// PostScript header
|
||||
writePSString("%%!PS-Adobe-3.0\n");
|
||||
writePSString("%%%%LanguageLevel: 1\n");
|
||||
writePSString("%%%%Title: %s\n", getSpoolMetaData()->getDescription().c_str());
|
||||
writePSString("%%%%Creator: %s\n", getSpoolMetaData()->getMimeType().c_str());
|
||||
writePSString("%%%%CreationDate: %s", getSpoolMetaData()->getCreationTime().c_str());
|
||||
writePSString("%%%%DocumentMedia: Plain %d %d white 0 ( )\n", getJobData()->getPaperRect().IntegerWidth(), getJobData()->getPaperRect().IntegerHeight());
|
||||
writePSString("%%%%Title: %s\n",
|
||||
getSpoolMetaData()->getDescription().c_str());
|
||||
writePSString("%%%%Creator: %s\n",
|
||||
getSpoolMetaData()->getMimeType().c_str());
|
||||
writePSString("%%%%CreationDate: %s",
|
||||
getSpoolMetaData()->getCreationTime().c_str());
|
||||
writePSString("%%%%DocumentMedia: Plain %d %d white 0 ( )\n",
|
||||
getJobData()->getPaperRect().IntegerWidth(),
|
||||
getJobData()->getPaperRect().IntegerHeight());
|
||||
writePSString("%%%%Pages: (atend)\n");
|
||||
writePSString("%%%%EndComments\n");
|
||||
|
||||
@@ -356,7 +371,8 @@ PSDriver::jobStart()
|
||||
|
||||
|
||||
void
|
||||
PSDriver::startRasterGraphics(int x, int y, int width, int height, int widthByte)
|
||||
PSDriver::startRasterGraphics(int x, int y, int width, int height,
|
||||
int widthByte)
|
||||
{
|
||||
bool color = getJobData()->getColor() == JobData::kColor;
|
||||
fCompressionMethod = -1;
|
||||
@@ -364,20 +380,18 @@ PSDriver::startRasterGraphics(int x, int y, int width, int height, int widthByte
|
||||
writePSString("/s %d string def\n", widthByte);
|
||||
writePSString("%d %d translate\n", x, y);
|
||||
writePSString("%d %d scale\n", width, height);
|
||||
if (color) {
|
||||
if (color)
|
||||
writePSString("%d %d 8\n", width, height); // 8 bpp
|
||||
} else {
|
||||
else
|
||||
writePSString("%d %d 1\n", width, height); // 1 bpp
|
||||
}
|
||||
writePSString("[%d 0 0 %d 0 0]\n", width, height);
|
||||
writePSString("{ currentfile s readhexstring pop }\n");
|
||||
if (color) {
|
||||
writePSString("false 3\n"); // single data source, 3 color components
|
||||
writePSString("colorimage\n");
|
||||
} else {
|
||||
} else
|
||||
writePSString("image\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* PS.h
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __PS_H
|
||||
#define __PS_H
|
||||
|
||||
|
||||
#include "GraphicsDriver.h"
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ class Halftone;
|
||||
|
||||
class PSDriver : public GraphicsDriver {
|
||||
public:
|
||||
PSDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap);
|
||||
PSDriver(BMessage* msg, PrinterData* printer_data,
|
||||
const PrinterCap* printer_cap);
|
||||
|
||||
protected:
|
||||
virtual bool startDoc();
|
||||
@@ -27,12 +28,11 @@ protected:
|
||||
private:
|
||||
void setupCTM();
|
||||
void jobStart();
|
||||
void startRasterGraphics(int x, int y, int width, int height, int widthByte);
|
||||
void startRasterGraphics(int x, int y, int width,
|
||||
int height, int widthByte);
|
||||
void endRasterGraphics();
|
||||
void rasterGraphics(
|
||||
int compression_method,
|
||||
const uchar *buffer,
|
||||
int size);
|
||||
void rasterGraphics(int compression_method,
|
||||
const uchar* buffer, int size);
|
||||
void jobEnd();
|
||||
|
||||
void StartFilterIfNeeded();
|
||||
@@ -46,4 +46,4 @@ private:
|
||||
FilterIO* fFilterIO;
|
||||
};
|
||||
|
||||
#endif /* __PS_H */
|
||||
#endif // __PS_H
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "PrinterData.h"
|
||||
|
||||
#include "PSCap.h"
|
||||
|
||||
#include "PrinterData.h"
|
||||
|
||||
#define TO72DPI(a) (a * 72.0f / 600.0f)
|
||||
|
||||
const PaperCap a3(
|
||||
@@ -99,11 +101,14 @@ const ColorCap *colors[] = {
|
||||
};
|
||||
|
||||
PSCap::PSCap(const PrinterData* printer_data)
|
||||
: PrinterCap(printer_data)
|
||||
:
|
||||
PrinterCap(printer_data)
|
||||
{
|
||||
}
|
||||
|
||||
int PSCap::countCap(CapID capid) const
|
||||
|
||||
int
|
||||
PSCap::countCap(CapID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case kPaper:
|
||||
@@ -119,7 +124,9 @@ int PSCap::countCap(CapID capid) const
|
||||
}
|
||||
}
|
||||
|
||||
const BaseCap **PSCap::enumCap(CapID capid) const
|
||||
|
||||
const BaseCap**
|
||||
PSCap::enumCap(CapID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case kPaper:
|
||||
@@ -135,7 +142,9 @@ const BaseCap **PSCap::enumCap(CapID capid) const
|
||||
}
|
||||
}
|
||||
|
||||
bool PSCap::isSupport(CapID capid) const
|
||||
|
||||
bool
|
||||
PSCap::isSupport(CapID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case kPaper:
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
* PSCap.h
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __PSCAP_H
|
||||
#define __PSCAP_H
|
||||
|
||||
|
||||
#include "PrinterCap.h"
|
||||
|
||||
|
||||
class PSCap : public PrinterCap {
|
||||
public:
|
||||
PSCap(const PrinterData* printer_data);
|
||||
@@ -16,4 +17,4 @@ public:
|
||||
virtual const BaseCap **enumCap(CapID) const;
|
||||
};
|
||||
|
||||
#endif /* __PSCAP_H */
|
||||
#endif // __PSCAP_H
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
* Ithamar R. Adema <ithamar.adema@team-embedded.nl>
|
||||
*/
|
||||
|
||||
|
||||
#include "PSData.h"
|
||||
|
||||
#include <Node.h>
|
||||
|
||||
#define PD_PPD_PATH "ps:ppd_path"
|
||||
|
||||
|
||||
void
|
||||
PSData::load()
|
||||
{
|
||||
@@ -19,6 +21,7 @@ PSData::load()
|
||||
fNode->ReadAttrString(PD_PPD_PATH, &fPPD);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PSData::save()
|
||||
{
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* Authors:
|
||||
* Ithamar R. Adema <ithamar.adema@team-embedded.nl>
|
||||
*/
|
||||
|
||||
#ifndef PSDATA_H
|
||||
#define PSDATA_H
|
||||
|
||||
|
||||
#include "PrinterData.h"
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
@@ -18,7 +19,11 @@ class BNode;
|
||||
|
||||
class PSData : public PrinterData {
|
||||
public:
|
||||
PSData(BNode *node) : PrinterData(node) {}
|
||||
PSData(BNode* node)
|
||||
:
|
||||
PrinterData(node)
|
||||
{
|
||||
}
|
||||
|
||||
// PrinterData overrides
|
||||
virtual void load();
|
||||
@@ -27,5 +32,4 @@ public:
|
||||
BString fPPD;
|
||||
};
|
||||
|
||||
|
||||
#endif /* PSDATA_H */
|
||||
#endif // PSDATA_H
|
||||
|
||||
@@ -5,18 +5,24 @@
|
||||
* Copyright 2010 Ithamar Adema.
|
||||
*/
|
||||
|
||||
#include "PS.h"
|
||||
#include "PSCap.h"
|
||||
#include "PSData.h"
|
||||
#include "PrinterDriver.h"
|
||||
#include "SelectPPDDlg.h"
|
||||
|
||||
#include <Entry.h>
|
||||
#include <Path.h>
|
||||
|
||||
#include "PrinterDriver.h"
|
||||
#include "PS.h"
|
||||
#include "PSCap.h"
|
||||
#include "PSData.h"
|
||||
#include "SelectPPDDlg.h"
|
||||
|
||||
|
||||
class PSPrinterDriver : public PrinterDriver {
|
||||
public:
|
||||
PSPrinterDriver(BNode *printerFolder) : PrinterDriver(printerFolder) {}
|
||||
PSPrinterDriver(BNode* printerFolder)
|
||||
:
|
||||
PrinterDriver(printerFolder)
|
||||
{
|
||||
}
|
||||
|
||||
const char* GetSignature() const
|
||||
{
|
||||
@@ -44,11 +50,12 @@ public:
|
||||
if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) == B_OK
|
||||
&& path.Append("ppd") == B_OK
|
||||
&& BEntry(path.Path()).Exists()) {
|
||||
SelectPPDDlg *dialog = new SelectPPDDlg(dynamic_cast<PSData*>(GetPrinterData()));
|
||||
SelectPPDDlg* dialog =
|
||||
new SelectPPDDlg(dynamic_cast<PSData*>
|
||||
(GetPrinterData()));
|
||||
if (dialog->Go() != B_OK)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return printerName;
|
||||
}
|
||||
|
||||
@@ -62,7 +69,8 @@ public:
|
||||
return new PSCap(printerData);
|
||||
}
|
||||
|
||||
GraphicsDriver *InstantiateGraphicsDriver(BMessage *settings, PrinterData *printerData, PrinterCap *printerCap)
|
||||
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
|
||||
PrinterData* printerData, PrinterCap* printerCap)
|
||||
{
|
||||
return new PSDriver(settings, printerData, printerCap);
|
||||
}
|
||||
|
||||
@@ -6,23 +6,24 @@
|
||||
* Ithamar R. Adema <ithamar.adema@team-embedded.nl>
|
||||
*/
|
||||
|
||||
|
||||
#include "SelectPPDDlg.h"
|
||||
#include "PPDParser.h"
|
||||
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
|
||||
#include <Button.h>
|
||||
#include <Message.h>
|
||||
#include <ListView.h>
|
||||
#include <ScrollView.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <StringItem.h>
|
||||
#include <Directory.h>
|
||||
#include <String.h>
|
||||
#include <Entry.h>
|
||||
#include <ListView.h>
|
||||
#include <Message.h>
|
||||
#include <Path.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringItem.h>
|
||||
|
||||
#include "PPDParser.h"
|
||||
|
||||
enum {
|
||||
kMsgCancel = 'stop',
|
||||
@@ -36,8 +37,11 @@ enum {
|
||||
class PPDStringItem : public BStringItem {
|
||||
public:
|
||||
PPDStringItem(const BString& text, const BString& path)
|
||||
: BStringItem(text.String()),
|
||||
fPPDPath(path) {}
|
||||
:
|
||||
BStringItem(text.String()),
|
||||
fPPDPath(path)
|
||||
{
|
||||
}
|
||||
|
||||
BString fPPDPath;
|
||||
};
|
||||
@@ -51,7 +55,8 @@ SelectPPDDlg::SelectPPDDlg(PSData *data)
|
||||
{
|
||||
SetResult(B_ERROR);
|
||||
|
||||
BButton *ok, *cancel;
|
||||
BButton* ok;
|
||||
BButton* cancel;
|
||||
|
||||
ok = new BButton("btn:ok", "OK", new BMessage(kMsgOK));
|
||||
ok->MakeDefault(true);
|
||||
@@ -62,9 +67,11 @@ SelectPPDDlg::SelectPPDDlg(PSData *data)
|
||||
|
||||
BScrollView* manuScroller, *printerScroller;
|
||||
fManufacturersListView = new BListView("olv:manufacturers");
|
||||
manuScroller=new BScrollView("scr:manufacturers", fManufacturersListView, 0, false, true);
|
||||
manuScroller = new BScrollView("scr:manufacturers", fManufacturersListView,
|
||||
0, false, true);
|
||||
fPrintersListView = new BListView("olv:printers");
|
||||
printerScroller=new BScrollView("scr:printers", fPrintersListView, 0, false, true);
|
||||
printerScroller = new BScrollView("scr:printers", fPrintersListView, 0,
|
||||
false, true);
|
||||
|
||||
fPrintersListView->SetSelectionMessage(new BMessage(kMsgPrinterSelected));
|
||||
fManufacturersListView->SetSelectionMessage(new BMessage(kMsgManuSelected));
|
||||
@@ -107,6 +114,7 @@ SelectPPDDlg::PopulateManufacturers(directory_which data_dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectPPDDlg::PopulatePrinters(directory_which data_dir)
|
||||
{
|
||||
@@ -135,12 +143,14 @@ SelectPPDDlg::PopulatePrinters(directory_which data_dir)
|
||||
BString modelName = parser.GetParameter("ModelName");
|
||||
BPath ppdPath = path;
|
||||
ppdPath.Append(name);
|
||||
fPrintersListView->AddItem(new PPDStringItem(modelName, ppdPath.Path()));
|
||||
fPrintersListView->AddItem(new PPDStringItem(modelName,
|
||||
ppdPath.Path()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectPPDDlg::PrinterSelected()
|
||||
{
|
||||
@@ -148,6 +158,7 @@ SelectPPDDlg::PrinterSelected()
|
||||
fOKButton->SetEnabled(idx >= 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectPPDDlg::Save()
|
||||
{
|
||||
@@ -156,12 +167,14 @@ SelectPPDDlg::Save()
|
||||
|
||||
idx = fPrintersListView->CurrentSelection();
|
||||
if (idx >= 0)
|
||||
ppdPath = dynamic_cast<PPDStringItem*>(fPrintersListView->ItemAt(idx))->fPPDPath;
|
||||
ppdPath = dynamic_cast<PPDStringItem*>
|
||||
(fPrintersListView->ItemAt(idx))->fPPDPath;
|
||||
|
||||
fPSData->fPPD = ppdPath;
|
||||
fPSData->save();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectPPDDlg::MessageReceived(BMessage* msg)
|
||||
{
|
||||
@@ -178,11 +191,9 @@ SelectPPDDlg::MessageReceived(BMessage *msg)
|
||||
SetResult(B_NO_ERROR);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case kMsgCancel:
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
DialogWindow::MessageReceived(msg);
|
||||
break;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
#ifndef SELECTPPDDLG_H
|
||||
#define SELECTPPDDLG_H
|
||||
|
||||
|
||||
#include <storage/FindDirectory.h>
|
||||
|
||||
#include "DialogWindow.h"
|
||||
#include "PSData.h"
|
||||
|
||||
#include <storage/FindDirectory.h>
|
||||
|
||||
class BListView;
|
||||
class BButton;
|
||||
class PSData;
|
||||
|
||||
|
||||
class SelectPPDDlg : public DialogWindow {
|
||||
public:
|
||||
SelectPPDDlg(PSData* data);
|
||||
@@ -27,4 +30,4 @@ private:
|
||||
PSData* fPSData;
|
||||
};
|
||||
|
||||
#endif /* SELECTPPDDLG_H */
|
||||
#endif // SELECTPPDDLG_H
|
||||
|
||||
Reference in New Issue
Block a user