Do the same for the JobSetupWindow and PrinterSetupWindow's Go()
methods too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38846 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fd7d3a7d40
commit
4cc17e8c78
@ -2,13 +2,13 @@
|
||||
|
||||
PDF Writer printer driver.
|
||||
|
||||
Copyright (c) 2001-2003 OpenBeOS.
|
||||
Copyright (c) 2001-2003 OpenBeOS.
|
||||
|
||||
Authors:
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
Simon Gauvin
|
||||
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
|
||||
@ -40,9 +40,9 @@ THE SOFTWARE.
|
||||
#include "DocInfoWindow.h"
|
||||
|
||||
static const char* includeKeys[] = {
|
||||
"doc_info",
|
||||
"doc_info",
|
||||
#if HAVE_FULLVERSION_PDF_LIB
|
||||
"master_password", "user_password", "permissions",
|
||||
"master_password", "user_password", "permissions",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
@ -56,14 +56,14 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
fSetupMsg = msg;
|
||||
fExitSem = create_sem(0, "JobSetup");
|
||||
fResult = B_ERROR;
|
||||
|
||||
|
||||
if (printerName) {
|
||||
BString title;
|
||||
title << printerName << " Job Setup";
|
||||
SetTitle(title.String());
|
||||
fPrinterName = printerName;
|
||||
}
|
||||
|
||||
|
||||
// ---- Ok, build a default job setup user interface
|
||||
BRect r;
|
||||
BBox *panel;
|
||||
@ -78,7 +78,7 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
int32 lastPage;
|
||||
bool allPages;
|
||||
char buffer[80];
|
||||
|
||||
|
||||
// PrinterDriver ensures that property exists
|
||||
fSetupMsg->FindInt32("copies", &copies);
|
||||
fSetupMsg->FindInt32("first_page", &firstPage);
|
||||
@ -92,13 +92,13 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
fSetupMsg->AddMessage("doc_info", &doc_info);
|
||||
}
|
||||
AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
|
||||
|
||||
|
||||
allPages = firstPage == 1 && lastPage == MAX_INT32;
|
||||
|
||||
r = Bounds();
|
||||
|
||||
// add a *dialog* background
|
||||
panel = new BBox(r, "top_panel", B_FOLLOW_ALL,
|
||||
panel = new BBox(r, "top_panel", B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||
B_PLAIN_BORDER);
|
||||
|
||||
@ -118,8 +118,8 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
|
||||
x = r.left + kMargin;
|
||||
y = r.top + kMargin;
|
||||
|
||||
|
||||
|
||||
|
||||
// add a "copies" input field
|
||||
|
||||
/* Simon: temporarily removed this code
|
||||
@ -130,7 +130,7 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
fCopies->ResizeToPreferred();
|
||||
fCopies->GetPreferredSize(&w, &h);
|
||||
panel->AddChild(fCopies);
|
||||
|
||||
|
||||
y += h + kMargin; // "new line"
|
||||
*/
|
||||
// add a "pages" label
|
||||
@ -167,9 +167,9 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
panel->AddChild(fRange);
|
||||
|
||||
x += w + kMargin;
|
||||
|
||||
|
||||
// add a "from" field
|
||||
if (allPages) {
|
||||
if (allPages) {
|
||||
buffer[0] = 0;
|
||||
} else {
|
||||
sprintf(buffer, "%d", (int)firstPage);
|
||||
@ -183,13 +183,13 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
panel->AddChild(fFrom);
|
||||
|
||||
x += w + kMargin;
|
||||
|
||||
|
||||
// add a "to" field
|
||||
if (allPages) {
|
||||
buffer[0] = 0;
|
||||
} else {
|
||||
sprintf(buffer, "%d", (int)lastPage);
|
||||
}
|
||||
}
|
||||
fTo = new BTextControl(BRect(x, y, x+100, y+20), "to_field", kToLabel, buffer,
|
||||
new BMessage(RANGE_TO_MSG));
|
||||
fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
|
||||
@ -217,15 +217,15 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
ok->MoveTo(x, ok->Frame().top); // put the ok bottom at bottom right corner
|
||||
panel->AddChild(ok);
|
||||
|
||||
// add a "Cancel" button
|
||||
// add a "Cancel" button
|
||||
cancel = new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||
cancel->ResizeToPreferred();
|
||||
cancel->GetPreferredSize(&w, &h);
|
||||
cancel->MoveTo(x - w - kMargin, y); // put cancel button left next the ok button
|
||||
panel->AddChild(cancel);
|
||||
|
||||
// add a "DocInfo" button
|
||||
BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG),
|
||||
// add a "DocInfo" button
|
||||
BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG),
|
||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||
button->GetPreferredSize(&w, &h);
|
||||
button->ResizeToPreferred();
|
||||
@ -234,15 +234,15 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
||||
|
||||
// Finally, add our panel to window
|
||||
AddChild(panel);
|
||||
|
||||
|
||||
// Auto resize window
|
||||
ResizeTo(ok->Frame().right + kMargin, ok->Frame().bottom + kMargin);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
JobSetupWindow::UpdateJobMessage()
|
||||
void
|
||||
JobSetupWindow::UpdateJobMessage()
|
||||
{
|
||||
int32 copies = 1;
|
||||
|
||||
@ -272,7 +272,7 @@ JobSetupWindow::~JobSetupWindow()
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
JobSetupWindow::QuitRequested()
|
||||
{
|
||||
release_sem(fExitSem);
|
||||
@ -281,7 +281,7 @@ JobSetupWindow::QuitRequested()
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
void
|
||||
JobSetupWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
@ -290,7 +290,7 @@ JobSetupWindow::MessageReceived(BMessage *msg)
|
||||
fResult = B_OK;
|
||||
release_sem(fExitSem);
|
||||
break;
|
||||
|
||||
|
||||
case CANCEL_MSG:
|
||||
release_sem(fExitSem);
|
||||
break;
|
||||
@ -309,17 +309,24 @@ JobSetupWindow::MessageReceived(BMessage *msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
status_t
|
||||
status_t
|
||||
JobSetupWindow::Go()
|
||||
{
|
||||
MoveTo(300,300);
|
||||
Show();
|
||||
acquire_sem(fExitSem);
|
||||
if (Lock()) Quit();
|
||||
return fResult;
|
||||
|
||||
while (acquire_sem(fExitSem) == B_INTERRUPTED) {
|
||||
}
|
||||
|
||||
// Cache the value as after Quit() this object is deleted.
|
||||
status_t result = fResult;
|
||||
if (Lock())
|
||||
Quit();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
PDF Writer printer driver.
|
||||
|
||||
Copyright (c) 2001 OpenBeOS.
|
||||
Copyright (c) 2001 OpenBeOS.
|
||||
|
||||
Authors:
|
||||
Authors:
|
||||
Philippe Houdoin
|
||||
Simon Gauvin
|
||||
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
|
||||
@ -50,17 +50,17 @@ PrinterSetupWindow::PrinterSetupWindow(char *printerName)
|
||||
SetTitle(title.String());
|
||||
} else
|
||||
SetTitle("Printer Setup");
|
||||
|
||||
|
||||
// ---- Ok, build a default job setup user interface
|
||||
BRect r;
|
||||
BButton *button;
|
||||
float x, y, w, h;
|
||||
font_height fh;
|
||||
|
||||
|
||||
r = Bounds();
|
||||
|
||||
// add a *dialog* background
|
||||
BBox *panel = new BBox(r, "top_panel", B_FOLLOW_ALL,
|
||||
BBox *panel = new BBox(r, "top_panel", B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||
B_PLAIN_BORDER);
|
||||
|
||||
@ -80,22 +80,22 @@ PrinterSetupWindow::PrinterSetupWindow(char *printerName)
|
||||
w = Bounds().Width();
|
||||
w -= 2 * kHorzMargin;
|
||||
h = 150;
|
||||
|
||||
|
||||
BBox * model_group = new BBox(BRect(x, y, x+w, y+h), "model_group", B_FOLLOW_ALL_SIDES);
|
||||
model_group->SetLabel(kModelLabel);
|
||||
|
||||
|
||||
BRect rlv = model_group->Bounds();
|
||||
|
||||
|
||||
rlv.InsetBy(kHorzMargin, kVertMargin);
|
||||
rlv.top += fh.ascent + fh.descent + fh.leading;
|
||||
rlv.right -= B_V_SCROLL_BAR_WIDTH;
|
||||
fModelList = new BListView(rlv, "model_list",
|
||||
B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES );
|
||||
|
||||
|
||||
BScrollView * sv = new BScrollView( "model_list_scrollview", fModelList,
|
||||
B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true );
|
||||
model_group->AddChild(sv);
|
||||
|
||||
|
||||
panel->AddChild(model_group);
|
||||
|
||||
y += (h + kInterSpace);
|
||||
@ -115,7 +115,7 @@ PrinterSetupWindow::PrinterSetupWindow(char *printerName)
|
||||
|
||||
x -= kInterSpace;
|
||||
|
||||
// add a "Cancel" button
|
||||
// add a "Cancel" button
|
||||
button = new BButton(BRect(x, y, x + 400, y), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
button->ResizeToPreferred();
|
||||
button->GetPreferredSize(&w, &h);
|
||||
@ -127,7 +127,7 @@ PrinterSetupWindow::PrinterSetupWindow(char *printerName)
|
||||
|
||||
panel->ResizeTo(Bounds().Width(), y);
|
||||
ResizeTo(Bounds().Width(), y);
|
||||
|
||||
|
||||
float minWidth, maxWidth, minHeight, maxHeight;
|
||||
|
||||
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||
@ -139,11 +139,11 @@ PrinterSetupWindow::PrinterSetupWindow(char *printerName)
|
||||
|
||||
BDirectory Folder;
|
||||
BEntry entry;
|
||||
|
||||
|
||||
Folder.SetTo ("/boot/beos/etc/bubblejet");
|
||||
if (Folder.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
|
||||
while (Folder.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
if (entry.GetName(name) == B_NO_ERROR)
|
||||
@ -163,7 +163,7 @@ PrinterSetupWindow::~PrinterSetupWindow()
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
bool
|
||||
bool
|
||||
PrinterSetupWindow::QuitRequested()
|
||||
{
|
||||
release_sem(fExitSem);
|
||||
@ -172,7 +172,7 @@ PrinterSetupWindow::QuitRequested()
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
void
|
||||
void
|
||||
PrinterSetupWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
@ -181,48 +181,48 @@ PrinterSetupWindow::MessageReceived(BMessage *msg)
|
||||
// Test model selection (if any), save it in printerName node and return
|
||||
BNode spoolDir;
|
||||
BPath * path;
|
||||
|
||||
|
||||
if (fModelList->CurrentSelection() < 0)
|
||||
break;
|
||||
|
||||
|
||||
BStringItem * item = dynamic_cast<BStringItem*>
|
||||
(fModelList->ItemAt(fModelList->CurrentSelection()));
|
||||
|
||||
if (!item)
|
||||
break;
|
||||
|
||||
|
||||
path = new BPath();
|
||||
|
||||
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY, path);
|
||||
path->Append("printers");
|
||||
path->Append(fPrinterName);
|
||||
|
||||
|
||||
spoolDir.SetTo(path->Path());
|
||||
delete path;
|
||||
|
||||
|
||||
if (spoolDir.InitCheck() != B_OK) {
|
||||
BAlert * alert = new BAlert("Uh oh!",
|
||||
BAlert * alert = new BAlert("Uh oh!",
|
||||
"Couldn't find printer spool directory.", "OK");
|
||||
alert->Go();
|
||||
} else {
|
||||
spoolDir.WriteAttr("printer_model", B_STRING_TYPE, 0, item->Text(),
|
||||
} else {
|
||||
spoolDir.WriteAttr("printer_model", B_STRING_TYPE, 0, item->Text(),
|
||||
strlen(item->Text()));
|
||||
fResult = B_OK;
|
||||
}
|
||||
|
||||
|
||||
release_sem(fExitSem);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case CANCEL_MSG:
|
||||
fResult = B_ERROR;
|
||||
release_sem(fExitSem);
|
||||
break;
|
||||
|
||||
|
||||
case MODEL_MSG:
|
||||
fOkButton->SetEnabled((fModelList->CurrentSelection() >= 0));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
inherited::MessageReceived(msg);
|
||||
break;
|
||||
@ -231,14 +231,19 @@ PrinterSetupWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
status_t
|
||||
status_t
|
||||
PrinterSetupWindow::Go()
|
||||
{
|
||||
MoveTo(300, 300);
|
||||
Show();
|
||||
acquire_sem(fExitSem);
|
||||
Lock();
|
||||
Quit();
|
||||
|
||||
return fResult;
|
||||
while (acquire_sem(fExitSem) == B_INTERRUPTED) {
|
||||
}
|
||||
|
||||
// cache the value as after Quit() this object is deleted
|
||||
status_t result = fResult;
|
||||
if (Lock())
|
||||
Quit();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user