xref: /haiku/src/libs/print/libprint/UIDriver.cpp (revision b06a48ab8f30b45916a9c157b992827779182163)
1 /*
2  * UIDriver.cpp
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  */
5 
6 #include <Message.h>
7 
8 #include "UIDriver.h"
9 #include "JobData.h"
10 #include "PrinterData.h"
11 #include "JobSetupDlg.h"
12 #include "PageSetupDlg.h"
13 #include "DbgMsg.h"
14 
15 UIDriver::UIDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
16 	: fMsg(msg), fPrinterData(printer_data), fPrinterCap(printer_cap)
17 {
18 }
19 
20 UIDriver::~UIDriver()
21 {
22 }
23 
24 BMessage *UIDriver::configPage()
25 {
26 	BMessage *clone_msg = new BMessage(*fMsg);
27 	JobData *job_data = new JobData(clone_msg, fPrinterCap, JobData::kPageSettings);
28 
29 	if (doPageSetup(job_data,fPrinterData, fPrinterCap) < 0) {
30 		delete clone_msg;
31 		clone_msg = NULL;
32 	} else {
33 		clone_msg->what = 'okok';
34 	}
35 
36 	delete job_data;
37 	return clone_msg;
38 }
39 
40 BMessage *UIDriver::configJob()
41 {
42 	BMessage *clone_msg = new BMessage(*fMsg);
43 	JobData *job_data = new JobData(clone_msg, fPrinterCap, JobData::kJobSettings);
44 
45 	if (doJobSetup(job_data, fPrinterData, fPrinterCap) < 0) {
46 		delete clone_msg;
47 		clone_msg = NULL;
48 	} else {
49 		clone_msg->what = 'okok';
50 	}
51 
52 	delete job_data;
53 	return clone_msg;
54 }
55 
56 long UIDriver::doPageSetup(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap)
57 {
58 	PageSetupDlg *dlg = new PageSetupDlg(job_data, printer_data, printer_cap);
59 	return dlg->Go();
60 }
61 
62 long UIDriver::doJobSetup(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap)
63 {
64 	JobSetupDlg *dlg = new JobSetupDlg(job_data, printer_data, printer_cap);
65 	return dlg->Go();
66 }
67