Looks like I _HAD_ screwed something. Fixed some wrong stuff about printjob's settings, implemented more functions. Communication with the print_server should be ok, and also settings. Now comes the hard part: setting up the spool file. Any hint ?

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11532 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-03-02 14:03:28 +00:00
parent 59ad83d0d9
commit 41d64d6792

View File

@ -92,6 +92,8 @@ BPrintJob::ConfigJob()
void void
BPrintJob::CancelJob() BPrintJob::CancelJob()
{ {
// TODO: For real
stop_the_show = 1;
} }
@ -117,9 +119,7 @@ BPrintJob::CanContinue()
void void
BPrintJob::DrawView(BView *a_view, BPrintJob::DrawView(BView *view, BRect rect, BPoint where)
BRect a_rect,
BPoint where)
{ {
} }
@ -137,8 +137,14 @@ BPrintJob::Settings()
void void
BPrintJob::SetSettings(BMessage *a_msg) BPrintJob::SetSettings(BMessage *message)
{ {
if (message != NULL) {
HandlePageSetup(message);
HandlePrintSetup(message);
delete setup_msg;
setup_msg = message;
}
} }
@ -165,7 +171,7 @@ BPrintJob::IsSettingsMessageValid(BMessage *message) const
BRect BRect
BPrintJob::PaperRect() BPrintJob::PaperRect()
{ {
if (!paper_size.IsValid()) if (default_setup_msg == NULL)
LoadDefaultSettings(); LoadDefaultSettings();
return paper_size; return paper_size;
@ -175,17 +181,39 @@ BPrintJob::PaperRect()
BRect BRect
BPrintJob::PrintableRect() BPrintJob::PrintableRect()
{ {
if (!usable_size.IsValid()) if (default_setup_msg == NULL)
LoadDefaultSettings(); LoadDefaultSettings();
return usable_size; return usable_size;
} }
void void
BPrintJob::GetResolution(int32 *xdpi, int32 *ydpi) BPrintJob::GetResolution(int32 *xdpi, int32 *ydpi)
{ {
*xdpi = v_xres; int32 xres = -1, yres = -1;
*ydpi = v_yres;
const BMessage *message = NULL;
if (setup_msg != NULL)
message = setup_msg;
else {
if (default_setup_msg == NULL)
LoadDefaultSettings();
message = default_setup_msg;
}
if (message != NULL) {
if (message->HasInt32(PSRV_FIELD_XRES))
message->FindInt32(PSRV_FIELD_XRES, &xres);
if (message->HasInt32(PSRV_FIELD_YRES))
message->FindInt32(PSRV_FIELD_YRES, &yres);
}
if (xdpi != NULL)
*xdpi = xres;
if (ydpi != NULL)
*ydpi = yres;
} }
@ -195,6 +223,7 @@ BPrintJob::FirstPage()
return first_page; return first_page;
} }
int32 int32
BPrintJob::LastPage() BPrintJob::LastPage()
{ {
@ -205,9 +234,20 @@ BPrintJob::LastPage()
int32 int32
BPrintJob::PrinterType(void *) const BPrintJob::PrinterType(void *) const
{ {
return B_COLOR_PRINTER; EnsureValidMessenger();
BMessage message(PSRV_GET_ACTIVE_PRINTER);
BMessage reply;
sPrintServer->SendMessage(&message, &reply);
int32 type = B_COLOR_PRINTER;
reply.FindInt32("color", &type);
return type;
} }
#if 0 #if 0
#pragma mark ----- PRIVATE ----- #pragma mark ----- PRIVATE -----
#endif #endif
@ -229,12 +269,22 @@ BPrintJob::MangleName(char *filename)
void void
BPrintJob::HandlePageSetup(BMessage *setup) BPrintJob::HandlePageSetup(BMessage *setup)
{ {
} }
bool bool
BPrintJob::HandlePrintSetup(BMessage *setup) BPrintJob::HandlePrintSetup(BMessage *message)
{ {
if (message->HasRect(PSRV_FIELD_PRINTABLE_RECT))
message->FindRect(PSRV_FIELD_PRINTABLE_RECT, &usable_size);
if (message->HasRect(PSRV_FIELD_PAPER_RECT))
message->FindRect(PSRV_FIELD_PAPER_RECT, &paper_size);
if (message->HasInt32(PSRV_FIELD_FIRST_PAGE))
message->FindInt32(PSRV_FIELD_FIRST_PAGE, &first_page);
if (message->HasInt32(PSRV_FIELD_LAST_PAGE))
message->FindInt32(PSRV_FIELD_LAST_PAGE, &last_page);
return true; return true;
} }
@ -286,14 +336,20 @@ BPrintJob::LoadDefaultSettings()
EnsureValidMessenger(); EnsureValidMessenger();
BMessage message(PSRV_GET_DEFAULT_SETTINGS); BMessage message(PSRV_GET_DEFAULT_SETTINGS);
BMessage reply; BMessage *reply = new BMessage;
sPrintServer->SendMessage(&message, &reply); sPrintServer->SendMessage(&message, reply);
if (reply.HasRect("paper_rect")) if (reply->HasRect(PSRV_FIELD_PAPER_RECT))
reply.FindRect("paper_rect", &paper_size); reply->FindRect(PSRV_FIELD_PAPER_RECT, &paper_size);
if (reply.HasRect("printable_rect")) if (reply->HasRect(PSRV_FIELD_PRINTABLE_RECT))
reply.FindRect("printable_rect", &usable_size); reply->FindRect(PSRV_FIELD_PRINTABLE_RECT, &usable_size);
// Should never happen, but anyway...
if (default_setup_msg != NULL)
delete default_setup_msg;
default_setup_msg = reply;
} }