*
* \author Lars Gullik Bjønnes
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insetinclude.h"
+
#include "buffer.h"
#include "buffer_funcs.h"
#include "bufferlist.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "latexrunparams.h"
-#include "Lsstream.h"
#include "lyxlex.h"
-#include "lyxrc.h"
#include "metricsinfo.h"
-#include "dimension.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
#include "frontends/Painter.h"
-#include "support/filetools.h"
+#include "graphics/PreviewedInset.h"
+#include "graphics/PreviewImage.h"
+
#include "support/FileInfo.h"
#include "support/FileMonitor.h"
+#include "support/filetools.h"
#include "support/lstrings.h" // contains
#include "support/tostr.h"
-#include "graphics/PreviewedInset.h"
-#include "graphics/PreviewImage.h"
-
#include <boost/bind.hpp>
-#include <cstdlib>
+#include "support/std_sstream.h"
using namespace lyx::support;
-using std::ostream;
using std::endl;
-using std::vector;
-using std::pair;
using std::auto_ptr;
+using std::ostream;
+using std::pair;
+using std::vector;
extern BufferList bufferlist;
return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- case LFUN_INSET_EDIT:
+ if (button_.box().contains(cmd.x, cmd.y))
+ InsetIncludeMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ case LFUN_INSET_DIALOG_SHOW:
InsetIncludeMailer(*this).showDialog(cmd.view());
return DISPATCHED;
}
-void InsetInclude::write(Buffer const *, ostream & os) const
+void InsetInclude::write(Buffer const &, ostream & os) const
+{
+ write(os);
+}
+
+
+void InsetInclude::write(ostream & os) const
{
os << "Include " << params_.cparams.getCommand() << '\n'
<< "preview " << tostr(params_.cparams.preview()) << '\n';
}
-void InsetInclude::read(Buffer const *, LyXLex & lex)
+void InsetInclude::read(Buffer const &, LyXLex & lex)
+{
+ read(lex);
+}
+
+
+void InsetInclude::read(LyXLex & lex)
{
params_.cparams.read(lex);
}
-bool InsetInclude::display() const
-{
- return !(params_.flag == INPUT);
-}
-
-
-string const InsetInclude::getScreenLabel(Buffer const *) const
+string const InsetInclude::getScreenLabel(Buffer const &) const
{
string temp;
}
-int InsetInclude::latex(Buffer const * buffer, ostream & os,
+int InsetInclude::latex(Buffer const & buffer, ostream & os,
LatexRunParams const & runparams) const
{
string incfile(params_.cparams.getContents());
Buffer * tmp = bufferlist.getBuffer(getFileName());
// FIXME: this should be a GUI warning
- if (tmp->params.textclass != buffer->params.textclass) {
+ if (tmp->params.textclass != buffer.params.textclass) {
lyxerr << "WARNING: Included file `"
<< MakeDisplayPath(getFileName())
<< "' has textclass `"
<< tmp->params.getLyXTextClass().name()
<< "' while parent file has textclass `"
- << buffer->params.getLyXTextClass().name()
+ << buffer.params.getLyXTextClass().name()
<< "'." << endl;
//return 0;
}
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".tex");
- if (!buffer->tmppath.empty() && !runparams.nice) {
+ if (!buffer.tmppath.empty() && !runparams.nice) {
incfile = subst(incfile, '/','@');
#ifdef __EMX__
incfile = subst(incfile, ':', '$');
#endif
- writefile = AddName(buffer->tmppath, incfile);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
writefile = ChangeExtension(writefile, ".tex");
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->markDepClean(buffer->tmppath);
+ tmp->markDepClean(buffer.tmppath);
tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()),
runparams, false);
}
-int InsetInclude::ascii(Buffer const *, ostream & os, int) const
+int InsetInclude::ascii(Buffer const &, ostream & os, int) const
{
if (isVerbatim())
os << GetFileContents(getFileName());
}
-int InsetInclude::linuxdoc(Buffer const * buffer, ostream & os) const
+int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os) const
{
string incfile(params_.cparams.getContents());
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".sgml");
- if (!buffer->tmppath.empty() && !buffer->niceFile) {
+ if (!buffer.tmppath.empty() && !buffer.niceFile) {
incfile = subst(incfile, '/','@');
- writefile = AddName(buffer->tmppath, incfile);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->makeLinuxDocFile(writefile, buffer->niceFile, true);
+ tmp->makeLinuxDocFile(writefile, buffer.niceFile, true);
}
if (isVerbatim()) {
}
-int InsetInclude::docbook(Buffer const * buffer, ostream & os,
+int InsetInclude::docbook(Buffer const & buffer, ostream & os,
bool /*mixcont*/) const
{
string incfile(params_.cparams.getContents());
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".sgml");
- if (!buffer->tmppath.empty() && !buffer->niceFile) {
+ if (!buffer.tmppath.empty() && !buffer.niceFile) {
incfile = subst(incfile, '/','@');
- writefile = AddName(buffer->tmppath, incfile);
+ writefile = AddName(buffer.tmppath, incfile);
} else
writefile = getFileName();
if (IsLyXFilename(getFileName()))
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
- tmp->makeDocBookFile(writefile, buffer->niceFile, true);
+ tmp->makeDocBookFile(writefile, buffer.niceFile, true);
}
if (isVerbatim()) {
string incfile(params_.cparams.getContents());
string writefile;
- Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
+ Buffer const & b = *bufferlist.getBuffer(getMasterFilename());
- if (b && !b->tmppath.empty() && !b->niceFile && !isVerbatim()) {
+ if (!b.tmppath.empty() && !b.niceFile && !isVerbatim()) {
incfile = subst(incfile, '/','@');
- writefile = AddName(b->tmppath, incfile);
+ writefile = AddName(b.tmppath, incfile);
} else
writefile = getFileName();
// a file got loaded
Buffer * const tmp = bufferlist.getBuffer(getFileName());
if (tmp) {
- if (b)
- tmp->niceFile = b->niceFile;
+ tmp->niceFile = b.niceFile;
tmp->validate(features);
}
}
} else {
if (!set_label_) {
set_label_ = true;
- button_.update(getScreenLabel(mi.base.bv->buffer()),
+ button_.update(getScreenLabel(*mi.base.bv->buffer()),
editable() != NOT_EDITABLE);
}
button_.metrics(mi, dim);
}
+ int center_indent = (params_.flag == INPUT ? 0 :
+ (mi.base.textwidth - dim.wid) / 2);
+ Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
+ button_.setBox(b);
+
+ dim.wid = mi.base.textwidth;
dim_ = dim;
}
{
cache(pi.base.bv);
if (!preview_->previewReady()) {
- button_.draw(pi, x, y);
+ button_.draw(pi, x + button_.box().x1, y);
return;
}
if (!preview_->monitoring())
preview_->startMonitoring();
- pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(),
+ pi.pain.image(x + button_.box().x1, y - dim_.asc, dim_.wid, dim_.height(),
*(preview_->pimage()->image()));
}
ostringstream os;
LatexRunParams runparams;
runparams.flavor = LatexRunParams::LATEX;
- parent().latex(view()->buffer(), os, runparams);
+ parent().latex(*view()->buffer(), os, runparams);
return STRCONV(os.str());
}
if (lex.isOK()) {
InsetInclude inset(params);
- inset.read(0, lex);
+ inset.read(lex);
params = inset.params();
}
}
inset.set(params);
ostringstream data;
data << name_ << ' ';
- inset.write(0, data);
+ inset.write(data);
data << "\\end_inset\n";
return STRCONV(data.str());
}