* adjusted copyright
* small coding style cleanups * made the config window a bit more font sensitive * removed unused code in AboutRequested, since change 19593 there is no Be anymore in the about text git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24517 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
* Copyright 2002-2008, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
static const float a0_width = 2380.0;
|
static const float a0_width = 2380.0;
|
||||||
static const float a0_height = 3368.0;
|
static const float a0_height = 3368.0;
|
||||||
static const float a1_width = 1684.0;
|
static const float a1_width = 1684.0;
|
||||||
@@ -48,6 +49,7 @@ static const float ledger_height = 792.0;
|
|||||||
static const float p11x17_width = 792.0;
|
static const float p11x17_width = 792.0;
|
||||||
static const float p11x17_height = 1224.0;
|
static const float p11x17_height = 1224.0;
|
||||||
|
|
||||||
|
|
||||||
static struct PageFormat
|
static struct PageFormat
|
||||||
{
|
{
|
||||||
char *label;
|
char *label;
|
||||||
@@ -69,7 +71,9 @@ static struct PageFormat
|
|||||||
{"B5", b5_width, b5_height },
|
{"B5", b5_width, b5_height },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void GetPageFormat(float w, float h, BString& label) {
|
|
||||||
|
static void GetPageFormat(float w, float h, BString& label)
|
||||||
|
{
|
||||||
w = floor(w + 0.5); h = floor(h + 0.5);
|
w = floor(w + 0.5); h = floor(h + 0.5);
|
||||||
for (uint i = 0; i < sizeof(pageFormat) / sizeof(struct PageFormat); i ++) {
|
for (uint i = 0; i < sizeof(pageFormat) / sizeof(struct PageFormat); i ++) {
|
||||||
struct PageFormat& pf = pageFormat[i];
|
struct PageFormat& pf = pageFormat[i];
|
||||||
@@ -82,7 +86,9 @@ static void GetPageFormat(float w, float h, BString& label) {
|
|||||||
label << (w / unit) << "x" << (h / unit) << " in.";
|
label << (w / unit) << "x" << (h / unit) << " in.";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMessage* settings, AutoReply* sender)
|
|
||||||
|
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||||
|
BMessage* settings, AutoReply* sender)
|
||||||
: BWindow(ConfigWindow::GetWindowFrame(), "Page Setup",
|
: BWindow(ConfigWindow::GetWindowFrame(), "Page Setup",
|
||||||
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||||
, fKind(kind)
|
, fKind(kind)
|
||||||
@@ -90,11 +96,14 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
, fSettings(settings)
|
, fSettings(settings)
|
||||||
, fSender(sender)
|
, fSender(sender)
|
||||||
, fCurrentPrinter(NULL)
|
, fCurrentPrinter(NULL)
|
||||||
|
, fPageFormatText(NULL)
|
||||||
|
, fJobSetupText(NULL)
|
||||||
{
|
{
|
||||||
MimeTypeForSender(settings, fSenderMimeType);
|
MimeTypeForSender(settings, fSenderMimeType);
|
||||||
PrinterForMimeType();
|
PrinterForMimeType();
|
||||||
|
|
||||||
if (kind == kJobSetup) SetTitle("Print Setup");
|
if (kind == kJobSetup)
|
||||||
|
SetTitle("Print Setup");
|
||||||
|
|
||||||
BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL,
|
BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||||
@@ -109,36 +118,41 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
||||||
SetupPrintersMenu(menu);
|
SetupPrintersMenu(menu);
|
||||||
|
|
||||||
r.right = r.left + be_plain_font->StringWidth("Printer:") + menu->MaxContentWidth() + 10;
|
float width = be_plain_font->StringWidth("Printer:") + 10.0;
|
||||||
|
r.right = r.left + width + menu->MaxContentWidth() + 10;
|
||||||
fPrinters = new BMenuField(r, "Printer", "Printer:", menu);
|
fPrinters = new BMenuField(r, "Printer", "Printer:", menu);
|
||||||
fPrinters->SetDivider(be_plain_font->StringWidth("Printer:") + 10);
|
fPrinters->SetDivider(width);
|
||||||
panel->AddChild(fPrinters);
|
panel->AddChild(fPrinters);
|
||||||
top += fPrinters->Bounds().Height() + 10;
|
top += fPrinters->Bounds().Height() + 10;
|
||||||
|
|
||||||
// page format button
|
// page format button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON", "PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON",
|
||||||
|
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
||||||
|
|
||||||
// add description to button
|
// add description to button
|
||||||
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top);
|
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top);
|
||||||
BStringView *stringView = AddStringView(panel, r, "Paper Setup:");
|
BStringView *stringView = AddStringView(panel, r, "Paper Setup:");
|
||||||
stringView->ResizeToPreferred();
|
stringView->ResizeToPreferred();
|
||||||
r = stringView->Frame();
|
r = stringView->Frame();
|
||||||
r.right = panel->Bounds().right;
|
|
||||||
r.OffsetBy(0, r.Height());
|
r.OffsetBy(0, r.Height());
|
||||||
fPageFormatText = AddStringView(panel, r, "");
|
fPageFormatText = AddStringView(panel, r, "");
|
||||||
|
fPageFormatText->ResizeToPreferred();
|
||||||
top = fPageSetup->Frame().bottom + 15;
|
top = fPageSetup->Frame().bottom + 15;
|
||||||
|
|
||||||
// page selection button
|
// page selection button
|
||||||
fJobSetup = NULL;
|
fJobSetup = NULL;
|
||||||
if (kind == kJobSetup) {
|
if (kind == kJobSetup) {
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fJobSetup = AddPictureButton(panel, r, "Page Selection", "JOB_SETUP_ON", "JOB_SETUP_OFF", MSG_JOB_SETUP);
|
fJobSetup = AddPictureButton(panel, r, "Page Selection", "JOB_SETUP_ON",
|
||||||
|
"JOB_SETUP_OFF", MSG_JOB_SETUP);
|
||||||
// add description to button
|
// add description to button
|
||||||
r.OffsetTo(left + fJobSetup->Bounds().Width() + 5, top);
|
r.OffsetTo(left + fJobSetup->Bounds().Width() + 5, top);
|
||||||
stringView = AddStringView(panel, r, "Pages to Print:");
|
stringView = AddStringView(panel, r, "Pages to Print:");
|
||||||
stringView->ResizeToPreferred();
|
stringView->ResizeToPreferred();
|
||||||
r.OffsetBy(0, stringView->Frame().Height());
|
r.OffsetBy(0, stringView->Frame().Height());
|
||||||
fJobSetupText = AddStringView(panel, r, "");
|
fJobSetupText = AddStringView(panel, r, "");
|
||||||
|
fJobSetupText->ResizeToPreferred();
|
||||||
top = fJobSetup->Frame().bottom + 15;
|
top = fJobSetup->Frame().bottom + 15;
|
||||||
}
|
}
|
||||||
top += 5;
|
top += 5;
|
||||||
@@ -152,7 +166,8 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
BButton* cancel = new BButton(r, "Cancel", "Cancel", new BMessage(B_QUIT_REQUESTED));
|
BButton* cancel = new BButton(r, "Cancel", "Cancel",
|
||||||
|
new BMessage(B_QUIT_REQUESTED));
|
||||||
panel->AddChild(cancel);
|
panel->AddChild(cancel);
|
||||||
cancel->ResizeToPreferred();
|
cancel->ResizeToPreferred();
|
||||||
left = cancel->Frame().right + 10;
|
left = cancel->Frame().right + 10;
|
||||||
@@ -176,12 +191,16 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
UpdateSettings(true);
|
UpdateSettings(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigWindow::~ConfigWindow() {
|
ConfigWindow::~ConfigWindow()
|
||||||
if (fCurrentPrinter) fCurrentPrinter->Release();
|
{
|
||||||
|
if (fCurrentPrinter)
|
||||||
|
fCurrentPrinter->Release();
|
||||||
release_sem(fFinished);
|
release_sem(fFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::Go() {
|
|
||||||
|
void ConfigWindow::Go()
|
||||||
|
{
|
||||||
sem_id sid = create_sem(0, "finished");
|
sem_id sid = create_sem(0, "finished");
|
||||||
if (sid >= 0) {
|
if (sid >= 0) {
|
||||||
fFinished = sid;
|
fFinished = sid;
|
||||||
@@ -193,11 +212,15 @@ void ConfigWindow::Go() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::MessageReceived(BMessage* m) {
|
|
||||||
|
void ConfigWindow::MessageReceived(BMessage* m)
|
||||||
|
{
|
||||||
switch (m->what) {
|
switch (m->what) {
|
||||||
case MSG_PAGE_SETUP: Setup(kPageSetup);
|
case MSG_PAGE_SETUP:
|
||||||
|
Setup(kPageSetup);
|
||||||
break;
|
break;
|
||||||
case MSG_JOB_SETUP: Setup(kJobSetup);
|
case MSG_JOB_SETUP:
|
||||||
|
Setup(kJobSetup);
|
||||||
break;
|
break;
|
||||||
case MSG_PRINTER_SELECTED: {
|
case MSG_PRINTER_SELECTED: {
|
||||||
BString printer;
|
BString printer;
|
||||||
@@ -220,67 +243,54 @@ void ConfigWindow::MessageReceived(BMessage* m) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
kAbout =
|
kAbout =
|
||||||
"Printer Server\n"
|
"Printer Server\n"
|
||||||
"© 2001-2006 Haiku\n"
|
"© 2001-2008 Haiku\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\tIthamar R. Adema - Initial Implementation\n"
|
"\tIthamar R. Adema - Initial Implementation\n"
|
||||||
"\tMichael Pfeiffer - Release 1 and beyond\n"
|
"\tMichael Pfeiffer - Release 1 and beyond\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ConfigWindow::AboutRequested()
|
ConfigWindow::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *about = new BAlert("About Printer Server", kAbout, "OK");
|
BAlert *about = new BAlert("About Printer Server", kAbout, "OK");
|
||||||
BTextView *v = about->TextView();
|
|
||||||
if (v) {
|
|
||||||
rgb_color red = {255, 0, 51, 255};
|
|
||||||
rgb_color blue = {0, 102, 255, 255};
|
|
||||||
|
|
||||||
v->SetStylable(true);
|
|
||||||
char *text = (char*)v->Text();
|
|
||||||
char *s = text;
|
|
||||||
// set all Be in blue and red
|
|
||||||
while ((s = strstr(s, "Be")) != NULL) {
|
|
||||||
int32 i = s - text;
|
|
||||||
v->SetFontAndColor(i, i+1, NULL, 0, &blue);
|
|
||||||
v->SetFontAndColor(i+1, i+2, NULL, 0, &red);
|
|
||||||
s += 2;
|
|
||||||
}
|
|
||||||
// first text line
|
|
||||||
s = strchr(text, '\n');
|
|
||||||
BFont font;
|
|
||||||
v->GetFontAndColor(0, &font);
|
|
||||||
font.SetSize(12);
|
|
||||||
v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE);
|
|
||||||
};
|
|
||||||
about->Go();
|
about->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConfigWindow::FrameMoved(BPoint p) {
|
void ConfigWindow::FrameMoved(BPoint p)
|
||||||
|
{
|
||||||
BRect frame = GetWindowFrame();
|
BRect frame = GetWindowFrame();
|
||||||
frame.OffsetTo(p);
|
frame.OffsetTo(p);
|
||||||
SetWindowFrame(frame);
|
SetWindowFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect ConfigWindow::GetWindowFrame() {
|
|
||||||
|
BRect ConfigWindow::GetWindowFrame()
|
||||||
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked())
|
||||||
return Settings::GetSettings()->ConfigWindowFrame();
|
return Settings::GetSettings()->ConfigWindowFrame();
|
||||||
}
|
|
||||||
return BRect(30, 30, 300, 300);
|
return BRect(30, 30, 300, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::SetWindowFrame(BRect r) {
|
|
||||||
|
void ConfigWindow::SetWindowFrame(BRect r)
|
||||||
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked())
|
||||||
Settings::GetSettings()->SetConfigWindowFrame(r);
|
Settings::GetSettings()->SetConfigWindowFrame(r);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame, const char* name, const char* on, const char* off, uint32 what) {
|
|
||||||
|
BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
||||||
|
const char* name, const char* on, const char* off, uint32 what)
|
||||||
|
{
|
||||||
BBitmap* onBM = LoadBitmap(on);
|
BBitmap* onBM = LoadBitmap(on);
|
||||||
BBitmap* offBM = LoadBitmap(off);
|
BBitmap* offBM = LoadBitmap(off);
|
||||||
|
|
||||||
@@ -312,7 +322,9 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame, const
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
BStringView* ConfigWindow::AddStringView(BView* panel, BRect frame, const char* text) {
|
|
||||||
|
BStringView* ConfigWindow::AddStringView(BView* panel, BRect frame, const char* text)
|
||||||
|
{
|
||||||
// frame.bottom = frame.top ;
|
// frame.bottom = frame.top ;
|
||||||
BStringView* string = new BStringView(frame, "", text);
|
BStringView* string = new BStringView(frame, "", text);
|
||||||
string->SetViewColor(panel->ViewColor());
|
string->SetViewColor(panel->ViewColor());
|
||||||
@@ -321,11 +333,15 @@ BStringView* ConfigWindow::AddStringView(BView* panel, BRect frame, const char*
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::PrinterForMimeType() {
|
|
||||||
|
void ConfigWindow::PrinterForMimeType()
|
||||||
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (fCurrentPrinter) {
|
if (fCurrentPrinter) {
|
||||||
fCurrentPrinter->Release(); fCurrentPrinter = NULL;
|
fCurrentPrinter->Release();
|
||||||
|
fCurrentPrinter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked()) {
|
||||||
Settings* s = Settings::GetSettings();
|
Settings* s = Settings::GetSettings();
|
||||||
AppSettings* app = s->FindAppSettings(fSenderMimeType.String());
|
AppSettings* app = s->FindAppSettings(fSenderMimeType.String());
|
||||||
@@ -335,15 +351,18 @@ void ConfigWindow::PrinterForMimeType() {
|
|||||||
fPrinterName = fDefaultPrinter ? fDefaultPrinter->Name() : "";
|
fPrinterName = fDefaultPrinter ? fDefaultPrinter->Name() : "";
|
||||||
}
|
}
|
||||||
fCurrentPrinter = Printer::Find(fPrinterName);
|
fCurrentPrinter = Printer::Find(fPrinterName);
|
||||||
if (fCurrentPrinter) fCurrentPrinter->Acquire();
|
if (fCurrentPrinter)
|
||||||
|
fCurrentPrinter->Acquire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::SetupPrintersMenu(BMenu* menu) {
|
|
||||||
|
void ConfigWindow::SetupPrintersMenu(BMenu* menu)
|
||||||
|
{
|
||||||
// clear menu
|
// clear menu
|
||||||
for (int i = menu->CountItems() - 1; i >= 0; i --) {
|
while (menu->CountItems() != 0)
|
||||||
delete menu->RemoveItem(i);
|
delete menu->RemoveItem(0L);
|
||||||
}
|
|
||||||
// fill menu with printer names
|
// fill menu with printer names
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked()) {
|
||||||
@@ -355,22 +374,29 @@ void ConfigWindow::SetupPrintersMenu(BMenu* menu) {
|
|||||||
m = new BMessage(MSG_PRINTER_SELECTED);
|
m = new BMessage(MSG_PRINTER_SELECTED);
|
||||||
m->AddString("name", n.String());
|
m->AddString("name", n.String());
|
||||||
menu->AddItem(item = new BMenuItem(n.String(), m));
|
menu->AddItem(item = new BMenuItem(n.String(), m));
|
||||||
if (n == fPrinterName) item->SetMarked(true);
|
if (n == fPrinterName)
|
||||||
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::UpdateAppSettings(const char* mime, const char* printer) {
|
|
||||||
|
void ConfigWindow::UpdateAppSettings(const char* mime, const char* printer)
|
||||||
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked()) {
|
||||||
Settings* s = Settings::GetSettings();
|
Settings* s = Settings::GetSettings();
|
||||||
AppSettings* app = s->FindAppSettings(mime);
|
AppSettings* app = s->FindAppSettings(mime);
|
||||||
if (app) app->SetPrinter(printer);
|
if (app)
|
||||||
else s->AddAppSettings(new AppSettings(mime, printer));
|
app->SetPrinter(printer);
|
||||||
|
else
|
||||||
|
s->AddAppSettings(new AppSettings(mime, printer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::UpdateSettings(bool read) {
|
|
||||||
|
void ConfigWindow::UpdateSettings(bool read)
|
||||||
|
{
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked()) {
|
||||||
Settings* s = Settings::GetSettings();
|
Settings* s = Settings::GetSettings();
|
||||||
@@ -391,21 +417,25 @@ void ConfigWindow::UpdateSettings(bool read) {
|
|||||||
UpdateUI();
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::UpdateUI() {
|
|
||||||
|
void ConfigWindow::UpdateUI()
|
||||||
|
{
|
||||||
if (fCurrentPrinter == NULL) {
|
if (fCurrentPrinter == NULL) {
|
||||||
fPageSetup->SetEnabled(false);
|
fPageSetup->SetEnabled(false);
|
||||||
if (fJobSetup) {
|
if (fJobSetup) {
|
||||||
fJobSetup->SetEnabled(false);
|
fJobSetup->SetEnabled(false);
|
||||||
fJobSetupText->SetText("Undefined job settings");
|
fJobSetupText->SetText("Undefined job settings");
|
||||||
|
fJobSetupText->ResizeToPreferred();
|
||||||
}
|
}
|
||||||
fOk->SetEnabled(false);
|
fOk->SetEnabled(false);
|
||||||
fPageFormatText->SetText("Undefined paper format");
|
fPageFormatText->SetText("Undefined paper format");
|
||||||
|
fPageFormatText->ResizeToPreferred();
|
||||||
} else {
|
} else {
|
||||||
fPageSetup->SetEnabled(true);
|
fPageSetup->SetEnabled(true);
|
||||||
|
|
||||||
if (fJobSetup) {
|
if (fJobSetup)
|
||||||
fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty());
|
fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty());
|
||||||
}
|
|
||||||
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
|
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
|
||||||
fKind == kPageSetup && !fPageSettings.IsEmpty());
|
fKind == kPageSetup && !fPageSettings.IsEmpty());
|
||||||
|
|
||||||
@@ -417,12 +447,15 @@ void ConfigWindow::UpdateUI() {
|
|||||||
|
|
||||||
int32 orientation = 0;
|
int32 orientation = 0;
|
||||||
fPageSettings.FindInt32(PSRV_FIELD_ORIENTATION, &orientation);
|
fPageSettings.FindInt32(PSRV_FIELD_ORIENTATION, &orientation);
|
||||||
if (orientation == 0) pageFormat << ", Portrait";
|
if (orientation == 0)
|
||||||
else pageFormat << ", Landscape";
|
pageFormat << ", Portrait";
|
||||||
|
else
|
||||||
|
pageFormat << ", Landscape";
|
||||||
} else {
|
} else {
|
||||||
pageFormat << "Undefined paper format";
|
pageFormat << "Undefined paper format";
|
||||||
}
|
}
|
||||||
fPageFormatText->SetText(pageFormat.String());
|
fPageFormatText->SetText(pageFormat.String());
|
||||||
|
fPageFormatText->ResizeToPreferred();
|
||||||
|
|
||||||
// display information about job
|
// display information about job
|
||||||
if (fKind == kJobSetup) {
|
if (fKind == kJobSetup) {
|
||||||
@@ -436,26 +469,39 @@ void ConfigWindow::UpdateUI() {
|
|||||||
job << "All pages";
|
job << "All pages";
|
||||||
}
|
}
|
||||||
int32 copies;
|
int32 copies;
|
||||||
if (fJobSettings.FindInt32(PSRV_FIELD_COPIES, &copies) == B_OK && copies > 1) {
|
if (fJobSettings.FindInt32(PSRV_FIELD_COPIES, &copies)
|
||||||
|
== B_OK && copies > 1) {
|
||||||
job << ", " << copies << " copies";
|
job << ", " << copies << " copies";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
job << "Undefined job settings";
|
job << "Undefined job settings";
|
||||||
}
|
}
|
||||||
|
|
||||||
fJobSetupText->SetText(job.String());
|
fJobSetupText->SetText(job.String());
|
||||||
|
fJobSetupText->ResizeToPreferred();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fPageFormatText) {
|
||||||
|
if (fOk->Frame().right < fPageFormatText->Frame().right)
|
||||||
|
ResizeTo(fPageFormatText->Frame().right + 10, Bounds().bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fJobSetupText) {
|
||||||
|
if (fOk->Frame().right < fJobSetupText->Frame().right)
|
||||||
|
ResizeTo(fJobSetupText->Frame().right + 10, Bounds().bottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWindow::Setup(config_setup_kind kind) {
|
|
||||||
|
void ConfigWindow::Setup(config_setup_kind kind)
|
||||||
|
{
|
||||||
if (fCurrentPrinter) {
|
if (fCurrentPrinter) {
|
||||||
Hide();
|
Hide();
|
||||||
if (kind == kPageSetup) {
|
if (kind == kPageSetup) {
|
||||||
BMessage settings = fPageSettings;
|
BMessage settings = fPageSettings;
|
||||||
if (fCurrentPrinter->ConfigurePage(settings) == B_OK) {
|
if (fCurrentPrinter->ConfigurePage(settings) == B_OK) {
|
||||||
fPageSettings = settings;
|
fPageSettings = settings;
|
||||||
if (!fJobSettings.IsEmpty()) AddFields(&fJobSettings, &fPageSettings);
|
if (!fJobSettings.IsEmpty())
|
||||||
|
AddFields(&fJobSettings, &fPageSettings);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BMessage settings;
|
BMessage settings;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
* Copyright 2002-2008, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -29,7 +29,8 @@ class ConfigWindow : public BWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMessage* settings, AutoReply* sender);
|
ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||||
|
BMessage* settings, AutoReply* sender);
|
||||||
~ConfigWindow();
|
~ConfigWindow();
|
||||||
void Go();
|
void Go();
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ public:
|
|||||||
static void SetWindowFrame(BRect frame);
|
static void SetWindowFrame(BRect frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name, const char* on, const char* off, uint32 what);
|
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name,
|
||||||
|
const char* on, const char* off, uint32 what);
|
||||||
BStringView* AddStringView(BView* panel, BRect frame, const char* text);
|
BStringView* AddStringView(BView* panel, BRect frame, const char* text);
|
||||||
void PrinterForMimeType();
|
void PrinterForMimeType();
|
||||||
void SetupPrintersMenu(BMenu* menu);
|
void SetupPrintersMenu(BMenu* menu);
|
||||||
|
|||||||
Reference in New Issue
Block a user