Style cleanup.

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