(Alfredo) strip BufferView out of the graphics code.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6268 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-02-25 19:09:00 +00:00
parent 3ac369b71c
commit 5a6c9536f6
12 changed files with 57 additions and 79 deletions

View File

@ -368,55 +368,20 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
case FL_KEYPRESS:
{
lyxerr[Debug::WORKAREA] << "Workarea event: KEYPRESS" << endl;
KeySym keysym = 0;
char dummy[1];
XKeyEvent * xke = reinterpret_cast<XKeyEvent *>(ev);
XLookupString(xke, dummy, 1, &keysym, 0);
if (lyxerr.debugging(Debug::KEY)) {
char const * const tmp = XKeysymToString(key);
char const * const tmp2 = XKeysymToString(keysym);
string const stm = (tmp ? tmp : string());
string const stm2 = (tmp2 ? tmp2 : string());
lyxerr << "XWorkArea: Key is `" << stm
<< "' [" << key << "]\n"
<< "XWorkArea: Keysym is `" << stm2
<< "' [" << keysym << ']' << endl;
lyxerr << "XWorkArea: Key is `" << tmp
<< "' [" << key << "]" << endl;
}
// Note that we need this handling because of a bug
// in XForms 0.89, if this bug is resolved in the way I hope
// we can just use the keysym directly without looking
// at key at all. (Lgb)
KeySym ret_key = 0;
if (!key) {
// We might have to add more keysyms here also,
// we will do that as the issues arise. (Lgb)
if (keysym == XK_space) {
ret_key = keysym;
lyxerr[Debug::KEY] << "Using keysym [A]"
<< endl;
} else
break;
} else {
// It seems that this was a bit optimistic...
// With this hacking things seems to be better (Lgb)
//if (!iscntrl(key)) {
// ret_key = key;
// lyxerr[Debug::KEY]
// << "Using key [B]\n"
// << "Uchar["
// << static_cast<unsigned char>(key)
// << endl;
//} else {
ret_key = (keysym ? keysym : key);
lyxerr[Debug::KEY] << "Using keysym [B]"
<< endl;
//}
lyxerr << "Probably composing" << endl;
break;
}
KeySym ret_key = key;
unsigned int const ret_state = xke->state;
// If you have a better way to handle "wild-output" of

View File

@ -1,3 +1,12 @@
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* GraphicsConverter (startConversion): add the call to
ForkedCallQueue::add
* GraphicsLoader.[Ch],
* PreviewImage.[Ch],
* PreviewedInset.C: Removed unneeded BufferView
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* LoaderQueue.[Ch]: a simplification of the code, eliminated

View File

@ -12,8 +12,6 @@
#include "GraphicsLoader.h"
#include "BufferView.h"
#include "GraphicsCache.h"
#include "GraphicsCacheItem.h"
#include "GraphicsImage.h"
@ -21,9 +19,7 @@
#include "LoaderQueue.h"
#include "frontends/LyXView.h"
#include "frontends/Timeout.h"
#include <boost/weak_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/signals/trackable.hpp>
@ -44,7 +40,7 @@ struct Loader::Impl : boost::signals::trackable {
void createPixmap();
///
void startLoading(Inset const &, BufferView const &);
void startLoading(Inset const &);
/// The loading status of the image.
ImageStatus status_;
@ -70,8 +66,6 @@ private:
typedef std::list<Inset const *> InsetList;
///
InsetList insets;
///
boost::weak_ptr<BufferView const> view;
};
@ -132,11 +126,11 @@ void Loader::startLoading() const
}
void Loader::startLoading(Inset const & inset, BufferView const & bv) const
void Loader::startLoading(Inset const & inset) const
{
if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get())
return;
pimpl_->startLoading(inset, bv);
pimpl_->startLoading(inset);
}
@ -287,7 +281,7 @@ void Loader::Impl::createPixmap()
}
void Loader::Impl::startLoading(Inset const & inset, BufferView const & bv)
void Loader::Impl::startLoading(Inset const & inset)
{
if (status_ != WaitingToLoad)
return;
@ -297,7 +291,6 @@ void Loader::Impl::startLoading(Inset const & inset, BufferView const & bv)
it = std::find(it, end, &inset);
if (it == end)
insets.push_back(&inset);
view = bv.owner()->view();
LoaderQueue::get().touch(cached_item_);
}

View File

@ -66,10 +66,10 @@ public:
/// We are explicit about when we begin the loading process.
void startLoading() const;
/** starting loading of the image is conditional upon the
* inset being visible or not.
/** starting loading of the image is done by a urgency-based
* decision. Here we only call LoaderQueue::touch to request it.
*/
void startLoading(Inset const &, BufferView const &) const;
void startLoading(Inset const &) const;
/** Monitor any changes to the file.
* There is no point monitoring the file before startLoading() is

View File

@ -30,7 +30,7 @@ struct PreviewImage::Impl : public boost::signals::trackable {
///
~Impl();
///
Image const * image(Inset const &, BufferView const &);
Image const * image(Inset const &);
///
void statusChanged();
@ -93,10 +93,9 @@ int PreviewImage::width() const
}
Image const * PreviewImage::image(Inset const & inset,
BufferView const & bv) const
Image const * PreviewImage::image(Inset const & inset) const
{
return pimpl_->image(inset, bv);
return pimpl_->image(inset);
}
@ -117,11 +116,10 @@ PreviewImage::Impl::~Impl()
}
Image const * PreviewImage::Impl::image(Inset const & inset,
BufferView const & bv)
Image const * PreviewImage::Impl::image(Inset const & inset)
{
if (iloader_.status() == WaitingToLoad)
iloader_.startLoading(inset, bv);
iloader_.startLoading(inset);
return iloader_.image();
}

View File

@ -46,10 +46,8 @@ public:
/** If the image is not yet loaded (WaitingToLoad), then this method
* triggers that.
* inset and bv are passed so we can choose to load only
* those insets that are visible.
*/
Image const * image(Inset const & inset, BufferView const & bv) const;
Image const * image(Inset const & inset) const;
private:
/// Use the Pimpl idiom to hide the internals.

View File

@ -105,7 +105,7 @@ bool PreviewedInset::previewReady() const
if (!pimage_)
return false;
return pimage_->image(inset_, *view());
return pimage_->image(inset_);
}

View File

@ -1,3 +1,9 @@
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* insetgraphics.C (draw)
* insetinclude.C (draw): Eliminate Buferview argument in call to
PreviewImage::image
2003-02-25 John Levon <levon@movementarian.org>
* insetgraphicsParams.h:

View File

@ -348,7 +348,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
if (gparams.display != grfx::NoDisplay
&& cache_->loader.status() == grfx::WaitingToLoad)
cache_->loader.startLoading(*this, *bv);
cache_->loader.startLoading(*this);
if (!cache_->loader.monitoring())
cache_->loader.startMonitoring();

View File

@ -534,7 +534,7 @@ void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y,
int const h = a + d;
bv->painter().image(x, y - a, w, h,
*(preview_->pimage()->image(*this, *bv)));
*(preview_->pimage()->image(*this)));
xx += w;
}

View File

@ -211,7 +211,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
if (use_preview) {
pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front
*(preview_->pimage()->image(*this, *bv)));
*(preview_->pimage()->image(*this)));
} else {
pi.base.style = LM_ST_TEXT;
pi.base.font = font;

View File

@ -51,7 +51,6 @@
#include "textpainter.h"
#include "frontends/Dialogs.h"
#include "intl.h"
#include "insets/insetcommand.h"
#include "ref_inset.h"
using std::endl;
@ -798,8 +797,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_DIALOG_SHOW_NEW_INSET: {
string const & name = argument;
if (name == "ref") {
InsetCommandParams p(name);
string data = InsetCommandMailer::params2string(p);
string data = "LatexCommand \\ref{}\n\\end_inset\n\n";
bv->owner()->getDialogs().show(name, data, 0);
} else
result = UNDISPATCHED;
@ -807,13 +805,24 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
break;
case LFUN_REF_APPLY: {
InsetCommandParams params;
InsetCommandMailer::string2params(argument, params);
// argument comes with a head "LatexCommand " and a
// tail "\nend_inset\n\n". Strip them off.
string trimmed;
string body = split(argument, trimmed, ' ');
split(body, trimmed, '\n');
lyxerr << "passing '" << trimmed << "' to the math parser\n";
// It would be nice if RefInset could handle an
// InsetCommandParams arg, but for now we convert it to
// 'foo|++|bar|++|nonsense'.
string const tmp = params.getAsString();
MathAtom at;
if (!mathed_parse_normal(at, trimmed)) {
result = UNDISPATCHED;
break;
}
RefInset * tmp = at.nucleus()->asRefInset();
if (!tmp) {
result = UNDISPATCHED;
break;
}
InsetBase * base =
bv->owner()->getDialogs().getOpenInset("ref");
@ -824,9 +833,9 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
break;
}
*inset = RefInset(tmp);
*inset = *tmp;
} else {
mathcursor->insert(MathAtom(new RefInset(tmp)));
mathcursor->insert(at);
}
updateLocal(bv, true);
}