2001-03-27 10:43:10 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*
|
|
|
|
* \file ControlPrint.C
|
|
|
|
* \author Angus Leeming, a.leeming@.ac.uk
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2001-03-30 09:51:46 +00:00
|
|
|
#include <utility>
|
2001-03-27 10:43:10 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-04-26 18:40:38 +00:00
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "ButtonControllerBase.h"
|
2001-03-27 10:43:10 +00:00
|
|
|
#include "ControlPrint.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "PrinterParams.h"
|
|
|
|
#include "Liason.h"
|
2001-03-30 09:51:46 +00:00
|
|
|
#include "helper_funcs.h" // browseFile
|
2001-03-27 10:43:10 +00:00
|
|
|
#include "lyx_gui_misc.h" // WriteAlert
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "gettext.h"
|
2001-03-27 10:43:10 +00:00
|
|
|
|
|
|
|
using Liason::printBuffer;
|
|
|
|
using Liason::getPrinterParams;
|
2001-03-30 09:51:46 +00:00
|
|
|
using std::make_pair;
|
2001-03-27 10:43:10 +00:00
|
|
|
|
|
|
|
ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlDialog<ControlConnectBD>(lv, d)
|
|
|
|
{
|
|
|
|
d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrint::apply()
|
|
|
|
{
|
|
|
|
if (!lv_.view()->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
view().apply();
|
|
|
|
|
|
|
|
if (!printBuffer(lv_.buffer(), params())) {
|
|
|
|
WriteAlert(_("Error:"),
|
|
|
|
_("Unable to print"),
|
|
|
|
_("Check that your parameters are correct"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PrinterParams & ControlPrint::params() const
|
|
|
|
{
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(params_);
|
2001-03-27 10:43:10 +00:00
|
|
|
return *params_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrint::setParams()
|
|
|
|
{
|
|
|
|
if (params_) delete params_;
|
|
|
|
params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
|
2001-03-27 16:03:28 +00:00
|
|
|
|
|
|
|
bc().valid(); // so that the user can press Ok
|
2001-03-27 10:43:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrint::clearParams()
|
|
|
|
{
|
|
|
|
if (params_) {
|
|
|
|
delete params_;
|
|
|
|
params_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
string const ControlPrint::Browse(string const & in_name)
|
|
|
|
{
|
|
|
|
string const title = N_("Print to file");
|
|
|
|
string const pattern = "*.ps";
|
|
|
|
|
|
|
|
// Show the file browser dialog
|
|
|
|
return browseFile(&lv_, in_name, title, pattern,
|
|
|
|
make_pair(string(), string()),
|
|
|
|
make_pair(string(), string()));
|
|
|
|
}
|