mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
clean up
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10265 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b12b9a5677
commit
008dad0e3a
@ -29,6 +29,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include <map>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
namespace {
|
||||
@ -114,6 +115,14 @@ InsetBase::InsetBase(InsetBase const &)
|
||||
{}
|
||||
|
||||
|
||||
std::auto_ptr<InsetBase> InsetBase::clone() const
|
||||
{
|
||||
std::auto_ptr<InsetBase> b = doClone();
|
||||
BOOST_ASSERT(typeid(*b) == typeid(*this));
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
InsetBase::Code InsetBase::translate(std::string const & name)
|
||||
{
|
||||
static TranslatorMap const translator = build_translator();
|
||||
|
@ -12,17 +12,13 @@
|
||||
#ifndef INSETBASE_H
|
||||
#define INSETBASE_H
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
class CursorSlice;
|
||||
class DispatchResult;
|
||||
class FuncRequest;
|
||||
class FuncStatus;
|
||||
class LaTeXFeatures;
|
||||
@ -34,7 +30,6 @@ class MetricsInfo;
|
||||
class Dimension;
|
||||
class PainterInfo;
|
||||
class OutputParams;
|
||||
class UpdatableInset;
|
||||
|
||||
namespace lyx { namespace graphics { class PreviewLoader; } }
|
||||
|
||||
@ -64,13 +59,7 @@ public:
|
||||
/// virtual base class destructor
|
||||
virtual ~InsetBase() {}
|
||||
/// replicate ourselves
|
||||
std::auto_ptr<InsetBase> clone() const
|
||||
{
|
||||
std::auto_ptr<InsetBase> b = doClone();
|
||||
BOOST_ASSERT(typeid(*b) == typeid(*this));
|
||||
return b;
|
||||
}
|
||||
|
||||
std::auto_ptr<InsetBase> clone() const;
|
||||
|
||||
/// identification as math inset
|
||||
virtual MathInset * asMathInset() { return 0; }
|
||||
@ -338,7 +327,6 @@ public:
|
||||
virtual std::string const & getInsetName() const;
|
||||
/// used to toggle insets
|
||||
/// is the inset open?
|
||||
virtual bool isOpen() const { return false; }
|
||||
/// should this inset be handled like a normal charater
|
||||
virtual bool isChar() const { return false; }
|
||||
/// is this equivalent to a letter?
|
||||
@ -397,6 +385,8 @@ public:
|
||||
/// pretty arbitrary
|
||||
virtual int descent() const { return 10; }
|
||||
///
|
||||
int scroll() const { return 0; }
|
||||
///
|
||||
enum CollapseStatus {
|
||||
Collapsed,
|
||||
Inlined,
|
||||
|
@ -148,6 +148,9 @@ protected:
|
||||
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
///
|
||||
int scroll() const { return scx_; }
|
||||
|
||||
private:
|
||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||
|
||||
|
@ -190,43 +190,33 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
// update our idea of where we are
|
||||
setPosCache(pi, x, y);
|
||||
|
||||
BufferView * bv = pi.base.bv;
|
||||
bv->hideCursor();
|
||||
//BufferView * bv = pi.base.bv;
|
||||
////bv->hideCursor();
|
||||
|
||||
text_.draw(pi, x + border_, y);
|
||||
|
||||
if (drawFrame_)
|
||||
drawFrame(pi.pain, x, y);
|
||||
if (drawFrame_) {
|
||||
int const w = text_.width() + 2 * border_;
|
||||
int const a = text_.ascent() + border_;
|
||||
int const h = a + text_.descent() + border_;
|
||||
pi.pain.rectangle(x, y - a, w, h, frameColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// repaint the background if needed
|
||||
if (backgroundColor() != LColor::background)
|
||||
clearInset(pi.pain, x, y);
|
||||
if (backgroundColor() != LColor::background) {
|
||||
// repaint the background if needed
|
||||
int const w = text_.width() + 2 * border_;
|
||||
int const a = text_.ascent() + border_;
|
||||
int const h = a + text_.descent() + border_;
|
||||
pi.pain.fillRectangle(x, y - a, w, h, backgroundColor());
|
||||
}
|
||||
text_.drawSelection(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
void InsetText::drawFrame(Painter & pain, int x, int y) const
|
||||
{
|
||||
int const w = text_.width() + 2 * border_;
|
||||
int const a = text_.ascent() + border_;
|
||||
int const h = a + text_.descent() + border_;
|
||||
pain.rectangle(x, y - a, w, h, frameColor());
|
||||
}
|
||||
|
||||
|
||||
void InsetText::clearInset(Painter & pain, int x, int y) const
|
||||
{
|
||||
int const w = text_.width() + 2 * border_;
|
||||
int const a = text_.ascent() + border_;
|
||||
int const h = a + text_.descent() + border_;
|
||||
pain.fillRectangle(x, y - a, w, h, backgroundColor());
|
||||
}
|
||||
|
||||
|
||||
string const InsetText::editMessage() const
|
||||
{
|
||||
return _("Opened Text Inset");
|
||||
@ -289,7 +279,7 @@ int InsetText::plaintext(Buffer const & buf, ostream & os,
|
||||
asciiParagraph(buf, *it, os, runparams, ref_printed);
|
||||
|
||||
// FIXME: Give the total numbers of lines
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -368,11 +358,20 @@ void InsetText::setText(string const & data, LyXFont const & font)
|
||||
|
||||
void InsetText::setAutoBreakRows(bool flag)
|
||||
{
|
||||
if (flag != text_.autoBreakRows_) {
|
||||
text_.autoBreakRows_ = flag;
|
||||
if (!flag)
|
||||
removeNewlines();
|
||||
}
|
||||
if (flag == text_.autoBreakRows_)
|
||||
return;
|
||||
|
||||
text_.autoBreakRows_ = flag;
|
||||
if (flag)
|
||||
return;
|
||||
|
||||
// remove previously existing newlines
|
||||
ParagraphList::iterator it = paragraphs().begin();
|
||||
ParagraphList::iterator end = paragraphs().end();
|
||||
for (; it != end; ++it)
|
||||
for (int i = 0; i < it->size(); ++i)
|
||||
if (it->isNewline(i))
|
||||
it->erase(i);
|
||||
}
|
||||
|
||||
|
||||
@ -404,17 +403,6 @@ void InsetText::setViewCache(BufferView const * bv) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::removeNewlines()
|
||||
{
|
||||
ParagraphList::iterator it = paragraphs().begin();
|
||||
ParagraphList::iterator end = paragraphs().end();
|
||||
for (; it != end; ++it)
|
||||
for (int i = 0; i < it->size(); ++i)
|
||||
if (it->isNewline(i))
|
||||
it->erase(i);
|
||||
}
|
||||
|
||||
|
||||
LyXText * InsetText::getText(int i) const
|
||||
{
|
||||
return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
|
||||
|
@ -27,9 +27,7 @@ class BufferView;
|
||||
class CursorSlice;
|
||||
class Dimension;
|
||||
class LColor_color;
|
||||
class Painter;
|
||||
class ParagraphList;
|
||||
class Row;
|
||||
|
||||
|
||||
/**
|
||||
@ -150,14 +148,6 @@ private:
|
||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||
///
|
||||
void init();
|
||||
///
|
||||
void setCharFont(Buffer const &, int pos, LyXFont const & font);
|
||||
///
|
||||
void removeNewlines();
|
||||
///
|
||||
void drawFrame(Painter &, int x, int y) const;
|
||||
///
|
||||
void clearInset(Painter &, int x, int y) const;
|
||||
|
||||
///
|
||||
bool drawFrame_;
|
||||
|
@ -156,8 +156,6 @@ int RefInset::docbook(Buffer const & buf, std::ostream & os, OutputParams const
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RefInset::ref_type_info RefInset::types[] = {
|
||||
{ "ref", N_("Standard"), N_("Ref: ")},
|
||||
{ "eqref", N_("Equation"), N_("EqRef: ")},
|
||||
@ -167,3 +165,4 @@ RefInset::ref_type_info RefInset::types[] = {
|
||||
{ "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
|
||||
{ "", "", "" }
|
||||
};
|
||||
|
||||
|
@ -41,9 +41,6 @@ public:
|
||||
/// docbook output
|
||||
int docbook(Buffer const & buf, std::ostream & os, OutputParams const &) const;
|
||||
|
||||
/// small wrapper for the time being
|
||||
DispatchResult localDispatch(FuncRequest & cmd);
|
||||
|
||||
struct ref_type_info {
|
||||
///
|
||||
std::string latex_name;
|
||||
|
Loading…
Reference in New Issue
Block a user