+2000-07-05 Juergen Vigna <jug@sad.it>
+
+ * src/insets/lyxinset.h: changed Painter & in ascent(), descent()
+ calls to BufferView *.
+
+ * src/insets/insettext.C (checkAndActivateInset): small fix non
+ HIGHLY_EDITABLE insets should not be entered by cursor-move-over!
+
+ * src/insets/insetcommand.C (Read): Fixed as insets should read till
+ their \end_inset token!
+
2000-07-04 edscott <edscott@imp.mx>
* src/lyxrc.C, src/lyxrc.h, src/BufferView_pimpl.C,
extern char ascii_type;
extern void sigchldhandler(pid_t pid, int * status);
-extern int bibitemMaxWidth(Painter &, LyXFont const &);
+extern int bibitemMaxWidth(BufferView *, LyXFont const &);
static inline
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
- bibitemMaxWidth(bv_->painter(),
- textclasslist
- .TextClass(buffer_->
- params.textclass).defaultfont())) {
+ bibitemMaxWidth(bv_, textclasslist.
+ TextClass(buffer_->
+ params.textclass).defaultfont())) {
bv_->text->cursor.par()->bibkey->Edit(bv_, 0, 0, 0);
}
int start_x, end_x;
if (is_rtl) {
- start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
+ start_x = cursor.x() - tmpinset->width(bv_, font);
end_x = cursor.x();
} else {
start_x = cursor.x();
- end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
+ end_x = cursor.x() + tmpinset->width(bv_, font);
}
if (x > start_x && x < end_x
- && y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
- && y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
+ && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
+ && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
int start_x, end_x;
if (!is_rtl) {
- start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
+ start_x = cursor.x() - tmpinset->width(bv_, font);
end_x = cursor.x();
} else {
start_x = cursor.x();
- end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
+ end_x = cursor.x() + tmpinset->width(bv_, font);
}
if (x > start_x && x < end_x
- && y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
- && y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
+ && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
+ && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
}
-int InsetFig::ascent(Painter &, LyXFont const &) const
+int InsetFig::ascent(BufferView *, LyXFont const &) const
{
return hgh + 3;
}
-int InsetFig::descent(Painter &, LyXFont const &) const
+int InsetFig::descent(BufferView *, LyXFont const &) const
{
return 1;
}
-int InsetFig::width(Painter &, LyXFont const &) const
+int InsetFig::width(BufferView *, LyXFont const &) const
{
return wid + 2;
}
font.setSize(LyXFont::SIZE_TINY);
pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
}
- x += width(pain, font); // ?
+ x += width(bv, font); // ?
}
///
~InsetFig();
///
- int ascent(Painter &, LyXFont const & font) const;
+ int ascent(BufferView *, LyXFont const & font) const;
///
- int descent(Painter &, LyXFont const & font) const;
+ int descent(BufferView *, LyXFont const & font) const;
///
- int width(Painter &, LyXFont const & font) const;
+ int width(BufferView *, LyXFont const & font) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
scx = 0;
- mx_scx = abs((width(bv->painter(), font) - bv->workWidth()) / 2);
+ mx_scx = abs((width(bv, font) - bv->workWidth()) / 2);
}
// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
-int bibitemMaxWidth(Painter & pain, LyXFont const & font)
+int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
{
int w = 0;
// Does look like a hack? It is! (but will change at 0.13)
while (par) {
if (par->bibkey) {
- int wx = par->bibkey->width(pain, font);
+ int wx = par->bibkey->width(bv, font);
if (wx > w) w = wx;
}
par = par->next;
// ale070405
-string bibitemWidest(Painter & pain)
+string bibitemWidest(BufferView * bv)
{
int w = 0;
// Does look like a hack? It is! (but will change at 0.13)
while (par) {
if (par->bibkey) {
- int wx = par->bibkey->width(pain, font);
+ int wx = par->bibkey->width(bv, font);
if (wx > w) {
w = wx;
bkey = par->bibkey;
{
}
-int InsetButton::ascent(Painter & pain, LyXFont const &) const
+int InsetButton::ascent(BufferView * bv, LyXFont const &) const
{
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
string s = getScreenLabel();
if (Editable()) {
- pain.buttonText(0, 0, s, font,
- false, width, ascent, descent);
+ bv->painter().buttonText(0, 0, s, font,
+ false, width, ascent, descent);
} else {
- pain.rectText(0, 0, s, font,
- LColor::commandbg, LColor::commandframe,
- false, width, ascent, descent);
+ bv->painter().rectText(0, 0, s, font,
+ LColor::commandbg, LColor::commandframe,
+ false, width, ascent, descent);
}
return ascent;
}
-int InsetButton::descent(Painter & pain, LyXFont const &) const
+int InsetButton::descent(BufferView * bv, LyXFont const &) const
{
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
string s = getScreenLabel();
if (Editable()) {
- pain.buttonText(0, 0, s, font,
- false, width, ascent, descent);
+ bv->painter().buttonText(0, 0, s, font,
+ false, width, ascent, descent);
} else {
- pain.rectText(0, 0, s, font,
- LColor::commandbg, LColor::commandframe,
- false, width, ascent, descent);
+ bv->painter().rectText(0, 0, s, font,
+ LColor::commandbg, LColor::commandframe,
+ false, width, ascent, descent);
}
return descent;
}
-int InsetButton::width(Painter & pain, LyXFont const &) const
+int InsetButton::width(BufferView * bv, LyXFont const &) const
{
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
string s = getScreenLabel();
if (Editable()) {
- pain.buttonText(0, 0, s, font,
- false, width, ascent, descent);
+ bv->painter().buttonText(0, 0, s, font,
+ false, width, ascent, descent);
} else {
- pain.rectText(0, 0, s, font,
- LColor::commandbg, LColor::commandframe,
- false, width, ascent, descent);
+ bv->painter().rectText(0, 0, s, font,
+ LColor::commandbg, LColor::commandframe,
+ false, width, ascent, descent);
}
return width + 4;
}
InsetButton();
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
class LyXText;
using std::ostream;
+using std::endl;
InsetCollapsable::InsetCollapsable()
: UpdatableInset()
void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
{
+ string token;
+
if (lex.IsOK()) {
lex.next();
- string token = lex.GetString();
+ token = lex.GetString();
if (token == "collapsed") {
lex.next();
collapsed = lex.GetBool();
}
-int InsetCollapsable::ascent(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
- return ascent_collapsed(pain, font);
+ return ascent_collapsed(bv->painter(), font);
else
- return inset->ascent(pain, font) + TEXT_TO_TOP_OFFSET;
+ return inset->ascent(bv, font) + TEXT_TO_TOP_OFFSET;
}
-int InsetCollapsable::descent(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
- return descent_collapsed(pain, font);
+ return descent_collapsed(bv->painter(), font);
else
- return inset->descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
+ return inset->descent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
}
-int InsetCollapsable::width(Painter & pain, LyXFont const & font) const
+int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
return widthCollapsed;
- return inset->width(pain, font) + widthCollapsed;
+ return inset->width(bv, font) + widthCollapsed;
}
}
if (!cleared && ((inset->need_update == InsetText::FULL) ||
+ (inset->need_update == InsetText::INIT) ||
(top_x!=int(x)) || (top_baseline!=baseline))) {
- int w = owner()? width(pain, f) : pain.paperWidth();
- int h = ascent(pain,f) + descent(pain, f);
+ int w = owner()? width(bv, f) : pain.paperWidth();
+ int h = ascent(bv,f) + descent(bv, f);
int tx = (needFullRow() && !owner())? 0:int(x);
- int ty = baseline - ascent(pain,f);
+ int ty = baseline - ascent(bv,f);
if (ty < 0)
ty = 0;
UpdatableInset const * inset) const
{
int w;
- if (owner())
- w = static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset);
- else
- w = pain.paperWidth();
+ w = UpdatableInset::getMaxWidth(pain,inset);
- if (w < 0)
+ if (w < 0) {
return w;
-
+ }
+ w -= widthCollapsed;
+ // should be at least 30 pixels !!!
+ if (w < 30)
+ w = 30;
return w; // - top_x - widthCollapsed;
}
-
+#if 0
int InsetCollapsable::getMaxTextWidth(Painter & pain,
UpdatableInset const * inset) const
{
return getMaxWidth(pain, inset) - widthCollapsed;
}
-
+#endif
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
bool dodraw)
return;
}
}
- if (oldWidth != width(bv->painter(), font)) {
- oldWidth = width(bv->painter(), font);
+ if (oldWidth != width(bv, font)) {
+ oldWidth = width(bv, font);
inset->deleteLyXText(bv);
need_update = FULL;
if (owner()) {
///
void Write(Buffer const *, std::ostream &) const;
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const & f) const;
+ int width(BufferView *, LyXFont const & f) const;
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
// This function will not be necessary when lyx3
void InsetCommand::Read(Buffer const *, LyXLex & lex)
{
+ string token;
+
if (lex.EatLine()) {
- string t = lex.GetString();
- scanCommand(t);
+ token = lex.GetString();
+ scanCommand(token);
} else
lex.printError("InsetCommand: Parse error: `$$Token'");
+ while (lex.IsOK()) {
+ lex.nextToken();
+ token = lex.GetString();
+ if (token == "\\end_inset")
+ break;
+ }
+ if (token != "\\end_inset") {
+ lex.printError("Missing \\end_inset at this point. "
+ "Read: `$$Token'");
+ }
}
}
-int InsetError::ascent(Painter &, LyXFont const & font) const
+int InsetError::ascent(BufferView *, LyXFont const & font) const
{
LyXFont efont;
efont.setSize(font.size()).decSize();
}
-int InsetError::descent(Painter &, LyXFont const & font) const
+int InsetError::descent(BufferView *, LyXFont const & font) const
{
LyXFont efont;
efont.setSize(font.size()).decSize();
}
-int InsetError::width(Painter &, LyXFont const & font) const
+int InsetError::width(BufferView *, LyXFont const & font) const
{
LyXFont efont;
efont.setSize(font.size()).decSize();
// Draw as "Error" in a framed box
x += 1;
- pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
LColor::insetbg);
- pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
LColor::error);
pain.text(int(x + 2), baseline, _("Error"), efont);
- x += width(pain, font) - 1;
+ x += width(bv, font) - 1;
}
///
~InsetError();
///
- int ascent(Painter &, LyXFont const & font) const;
+ int ascent(BufferView *, LyXFont const & font) const;
///
- int descent(Painter &, LyXFont const & font) const;
+ int descent(BufferView *, LyXFont const & font) const;
///
- int width(Painter &, LyXFont const & font) const;
+ int width(BufferView *, LyXFont const & font) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
{}
-int InsetGraphics::ascent(Painter &, LyXFont const &) const
+int InsetGraphics::ascent(BufferView *, LyXFont const &) const
{
return 100;
}
-int InsetGraphics::descent(Painter &, LyXFont const &) const
+int InsetGraphics::descent(BufferView *, LyXFont const &) const
{
// this is not true if viewport is used and clip is not.
return 1;
}
-int InsetGraphics::width(Painter &, LyXFont const &) const
+int InsetGraphics::width(BufferView *, LyXFont const &) const
{
if (bb.isSet()) {
return bb.urx - bb.llx;
// This will draw the graphics. As for now we only draw a
// placeholder rectangele.
- pain.rectangle(int(x), baseline - ascent(pain, font),
- width(pain, font),
- ascent(pain, font) + descent(pain, font));
+ pain.rectangle(int(x), baseline - ascent(bv, font),
+ width(bv, font),
+ ascent(bv, font) + descent(bv, font));
}
///
InsetGraphics();
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
}
-int InsetInfo::ascent(Painter &, LyXFont const & font) const
+int InsetInfo::ascent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxAscent(font) + 1;
}
-int InsetInfo::descent(Painter &, LyXFont const & font) const
+int InsetInfo::descent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxDescent(font) + 1;
}
-int InsetInfo::width(Painter &, LyXFont const & font) const
+int InsetInfo::width(BufferView *, LyXFont const & font) const
{
return 6 + lyxfont::width(_("Note"), font);
}
// Draw as "Note" in a yellow box
x += 1;
- pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
LColor::notebg);
- pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
LColor::noteframe);
pain.text(int(x + 2), baseline, _("Note"), font);
- x += width(pain, font) - 1;
+ x += width(bv, font) - 1;
}
///
~InsetInfo();
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
}
-int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
{
// This function is a bit too simplistix and is just a
// "try to make a fit for all accents" approach, to
}
-int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
{
int max;
if (candisp) {
}
-int InsetLatexAccent::width(Painter &, LyXFont const & font) const
+int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
{
if (candisp)
return lyxfont::width(ic, font);
}
-bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
+bool InsetLatexAccent::DisplayISO8859_9(BufferView * bv, LyXFont const & font,
int baseline,
float & x) const
{
}
if (tmpic != ic) {
char ch = char(tmpic);
- pain.text(int(x), baseline, ch, font);
- x += width(pain, font);
+ bv->painter().text(int(x), baseline, ch, font);
+ x += width(bv, font);
return true;
}
else
Painter & pain = bv->painter();
if (lyxrc.font_norm == "iso8859-9")
- if (DisplayISO8859_9(pain, font, baseline, x))
+ if (DisplayISO8859_9(bv, font, baseline, x))
return;
/* draw it! */
// should also be considered.
if (candisp) {
- int asc = ascent(pain, font);
- int desc = descent(pain, font);
- int wid = width(pain, font);
+ int asc = ascent(bv, font);
+ int desc = descent(bv, font);
+ int wid = width(bv, font);
float x2 = x + (Rbearing(font) - Lbearing(font)) / 2.0;
float hg;
int y;
// closer to the top of the dot-less 'i' or 'j'.
char tmpic = ic; // store the ic when we
ic = 'x'; // calculates the ascent of
- asc = ascent(pain, font); // the dot-less version (here: 'x')
+ asc = ascent(bv, font); // the dot-less version (here: 'x')
ic = tmpic; // set the orig ic back
y = baseline - asc; // update to new y coord.
}
}
} else {
pain.fillRectangle(int(x + 1),
- baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font)
- + descent(pain, font) - 2);
- pain.rectangle(int(x + 1), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2);
+ baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font)
+ + descent(bv, font) - 2);
+ pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2);
pain.text(int(x + 2), baseline, contents, font);
}
- x += width(pain, font);
+ x += width(bv, font);
}
explicit
InsetLatexAccent(string const & string);
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
///
int Rbearing(LyXFont const & font) const;
///
- bool DisplayISO8859_9(Painter &, LyXFont const & font,
+ bool DisplayISO8859_9(BufferView *, LyXFont const & font,
int baseline, float & x) const;
///
void Write(Buffer const *, std::ostream &) const;
}
-int InsetQuotes::ascent(Painter &, LyXFont const & font) const
+int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxAscent(font);
}
-int InsetQuotes::descent(Painter &, LyXFont const & font) const
+int InsetQuotes::descent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxDescent(font);
}
-int InsetQuotes::width(Painter &, LyXFont const & font) const
+int InsetQuotes::width(BufferView *, LyXFont const & font) const
{
string text = DispString();
int w = 0;
string text = DispString();
bv->painter().text(int(x), baseline, text, font);
- x += width(bv->painter(), font);
+ x += width(bv, font);
}
InsetQuotes(char c, BufferParams const & params);
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
{}
-int InsetSpecialChar::ascent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxAscent(font);
}
-int InsetSpecialChar::descent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
{
return lyxfont::maxDescent(font);
}
-int InsetSpecialChar::width(Painter &, LyXFont const & font) const
+int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
{
switch (kind) {
case HYPHENATION:
{
font.setColor(LColor::special);
pain.text(int(x), baseline, "-", font);
- x += width(pain, font);
+ x += width(bv, font);
break;
}
case END_OF_SENTENCE:
{
font.setColor(LColor::special);
pain.text(int(x), baseline, ".", font);
- x += width(pain, font);
+ x += width(bv, font);
break;
}
case LDOTS:
{
font.setColor(LColor::special);
pain.text(int(x), baseline, ". . .", font);
- x += width(pain, font);
+ x += width(bv, font);
break;
}
case MENU_SEPARATOR:
xp[3] = ox; yp[3] = baseline;
pain.lines(xp, yp, 4, LColor::special);
- x += width(pain, font);
+ x += width(bv, font);
break;
}
case PROTECTED_SEPARATOR:
{
- float w = width(pain, font);
+ float w = width(bv, font);
int h = lyxfont::ascent('x', font);
int xp[4], yp[4];
explicit
InsetSpecialChar(Kind k);
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
}
-int InsetTabular::ascent(Painter &, LyXFont const &) const
+int InsetTabular::ascent(BufferView *, LyXFont const &) const
{
return tabular->GetAscentOfRow(0);
}
-int InsetTabular::descent(Painter &, LyXFont const &) const
+int InsetTabular::descent(BufferView *, LyXFont const &) const
{
return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0);
}
-int InsetTabular::width(Painter &, LyXFont const &) const
+int InsetTabular::width(BufferView *, LyXFont const &) const
{
return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
}
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
(top_x != int(x)) || (top_baseline != baseline))) {
#if 1
- int h = ascent(pain, font) + descent(pain, font);
+ int h = ascent(bv, font) + descent(bv, font);
int tx = display()? 0:top_x;
- int w = tx? width(pain, font):pain.paperWidth();
- int ty = baseline - ascent(pain, font);
+ int w = tx? width(bv, font):pain.paperWidth();
+ int ty = baseline - ascent(bv, font);
if (ty < 0)
ty = 0;
tabular->GetAdditionalHeight(cell+1);
}
}
- x += width(pain, font);
+ x += width(bv, font);
need_update = NONE;
}
locked = true;
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
- setPos(bv->painter(), x, y);
+ setPos(bv, x, y);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
bv->text->FinishUndo();
need_update = what;
bv->updateInset(this, mark_dirty);
if (what != NONE)
- resetPos(bv->painter());
+ resetPos(bv);
}
bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
if (inset == tabular->GetCellInset(actcell)) {
lyxerr[Debug::INSETS] << "OK" << endl;
the_locking_inset = tabular->GetCellInset(actcell);
- resetPos(bv->painter());
+ resetPos(bv);
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
inset_pos = cursor.pos();
} else if (the_locking_inset && (the_locking_inset == inset)) {
if (cursor.pos() == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
- resetPos(bv->painter());
+ resetPos(bv);
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
} else {
int ocell = actcell;
- setPos(bv->painter(), x, y);
+ setPos(bv, x, y);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
// int ocell = actcell,
int old = sel_pos_end;
- setPos(bv->painter(), x, y);
+ setPos(bv, x, y);
sel_pos_end = cursor.pos();
sel_cell_end = actcell;
if (old != sel_pos_end)
if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
|| (result == DISPATCHED_NOUPDATE)) {
- resetPos(bv->painter());
+ resetPos(bv);
return result;
}
result=DISPATCHED;
} else if (result == FINISHED) {
if ((action == LFUN_RIGHT) || (action == -1)) {
cursor.pos(inset_pos + 1);
- resetPos(bv->painter());
+ resetPos(bv);
}
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
++cell;
inset = tabular->GetCellInset(cell);
inset->update(bv, font, dodraw);
- maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
- maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
- changed = tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font)) || changed;
+ maxAsc = max(maxAsc, inset->ascent(bv, font));
+ maxDesc = max(maxDesc, inset->descent(bv, font));
+ changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
}
changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
}
-void InsetTabular::setPos(Painter & pain, int x, int y) const
+void InsetTabular::setPos(BufferView * bv, int x, int y) const
{
cursor.y(0);
cursor.pos(0);
++actcell,lx += tabular->GetWidthOfColumn(actcell) +
tabular->GetAdditionalWidth(actcell - 1));
cursor.pos(((actcell+1) * 2) - 1);
- resetPos(pain);
+ resetPos(bv);
if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
cursor.x(lx + top_x - 2);
} else {
cursor.pos(cursor.pos() - 1);
cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
}
- resetPos(pain);
+ resetPos(bv);
}
int InsetTabular::getCellXPos(int cell) const
ADD_TO_TABULAR_WIDTH);
}
-void InsetTabular::resetPos(Painter & pain) const
+void InsetTabular::resetPos(BufferView * bv) const
{
if (!locked)
return;
cursor.x(getCellXPos(actcell) + 2);
if (cursor.pos() % 2) {
LyXFont font(LyXFont::ALL_SANE);
- cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(pain,font) +
+ cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
tabular->GetBeginningOfTextInCell(actcell));
}
if ((!the_locking_inset ||
} else { // before the inset
cursor.pos(cursor.pos() + 1);
}
- resetPos(bv->painter());
+ resetPos(bv);
return DISPATCHED_NOUPDATE;
}
if (ActivateCellInset(bv, 0, 0, 0, true))
return DISPATCHED;
}
- resetPos(bv->painter());
+ resetPos(bv);
return DISPATCHED_NOUPDATE;
}
actcell = tabular->GetCellAbove(actcell);
if (actcell == ocell) // we moved out of the inset
return FINISHED;
- resetPos(bv->painter());
+ resetPos(bv);
return DISPATCHED_NOUPDATE;
}
actcell = tabular->GetCellBelow(actcell);
if (actcell == ocell) // we moved out of the inset
return FINISHED;
- resetPos(bv->painter());
+ resetPos(bv);
return DISPATCHED_NOUPDATE;
}
cursor.pos(cursor.pos() + 1);
if (!cellstart(cursor.pos()))
cursor.pos(cursor.pos() + 1);
- resetPos(bv->painter());
+ resetPos(bv);
return true;
}
cursor.pos(cursor.pos() - 1);
if (cellstart(cursor.pos()))
cursor.pos(cursor.pos() - 1);
- resetPos(bv->painter());
+ resetPos(bv);
return true;
}
// reset the curor pos first!
if (cursor.pos() % 2) { // behind the inset
cursor.pos(cursor.pos() - 1);
- resetPos(bv->painter());
+ resetPos(bv);
}
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
LyXFont font(LyXFont::ALL_SANE);
if (behind) {
- x = inset->x() + inset->width(bv->painter(), font);
- y = inset->descent(bv->painter(), font);
+ x = inset->x() + inset->width(bv, font);
+ y = inset->descent(bv, font);
}
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
if (cursor.pos() % 2) { // behind the inset
return (((x + top_x) < cursor.x()) &&
- ((x + top_x) > (cursor.x() - inset->width(bv->painter(),
+ ((x + top_x) > (cursor.x() - inset->width(bv,
LyXFont(LyXFont::ALL_SANE)))));
} else {
int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
return ((x1 > x2) &&
- (x1 < (x2 + inset->width(bv->painter(),
- LyXFont(LyXFont::ALL_SANE)))));
+ (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
}
}
cell = tabular->GetCellNumber(i,j);
inset = tabular->GetCellInset(cell);
inset->update(bv, font);
- tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
+ tabular->SetWidthOfCell(cell, inset->width(bv, font));
}
// cell = tabular->GetCellNumber(0, j);
// cx += tabular->GetWidthOfColumn(cell);
///
void Write(Buffer const *, std::ostream &) const;
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const & f) const;
+ int width(BufferView *, LyXFont const & f) const;
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
///
void HideInsetCursor(BufferView *);
///
- void setPos(Painter &, int x, int y) const;
+ void setPos(BufferView *, int x, int y) const;
///
UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
bool Delete();
///
int getCellXPos(int cell) const;
- void resetPos(Painter &) const;
+ void resetPos(BufferView *) const;
///
void RemoveTabularRow();
///
}
-int InsetText::ascent(Painter &, LyXFont const &) const
+int InsetText::ascent(BufferView * bv, LyXFont const &) const
{
+ long int y_temp = 0;
+ Row * row = TEXT(bv)->GetRowNearY(y_temp);
+ insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
return insetAscent;
}
-int InsetText::descent(Painter &, LyXFont const &) const
+int InsetText::descent(BufferView * bv, LyXFont const &) const
{
+ long int y_temp = 0;
+ Row * row = TEXT(bv)->GetRowNearY(y_temp);
+ insetDescent = TEXT(bv)->height - row->ascent_of_text() +
+ TEXT_TO_INSET_OFFSET;
return insetDescent;
}
-int InsetText::width(Painter &, LyXFont const &) const
+int InsetText::width(BufferView * bv, LyXFont const &) const
{
+ insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
return insetWidth;
}
// printf("WW1: %d\n",w);
return w;
}
-#if 0
+#if 1
if (owner()) {
- w = w - top_x; // + owner()->x();
+ w = w - top_x + owner()->x();
// printf("WW2: %d\n",w);
return w; // - top_x + owner()->x();
}
{
Painter & pain = bv->painter();
+ xpos = x;
+ UpdatableInset::draw(bv, f, baseline, x, cleared);
+
if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
(top_baseline!=baseline))) {
int w = insetWidth;
cleared = true;
need_update = FULL;
}
-
if (!cleared && (need_update == NONE))
return;
- xpos = x;
- UpdatableInset::draw(bv, f, baseline, x, cleared);
-
+ if (top_x != int(x)) {
+ need_update = INIT;
+ }
+
top_baseline = baseline;
top_x = int(x);
- top_y = baseline - ascent(pain, f);
- last_width = width(pain, f);
- last_height = ascent(pain, f) + descent(pain, f);
+ top_y = baseline - ascent(bv, f);
+ last_width = width(bv, f);
+ last_height = ascent(bv, f) + descent(bv, f);
if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
if (!cleared && (need_update == CURSOR)) {
- x += width(pain, f);
+ x += width(bv, f);
need_update = NONE;
return;
}
LColor::background);
}
x += insetWidth - TEXT_TO_INSET_OFFSET;
- need_update = NONE;
+ if (need_update != INIT)
+ need_update = NONE;
}
int x, y;
Inset * inset =
static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+ if (!inset || inset->Editable() != Inset::HIGHLY_EDITABLE)
+ return false;
LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
if (behind) {
- x = inset->width(bv->painter(), font);
- y = inset->descent(bv->painter(), font);
+ x = inset->width(bv, font);
+ y = inset->descent(bv, font);
} else {
x = y = 0;
}
int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
{
- return UpdatableInset::getMaxWidth(pain, inset) - (2*TEXT_TO_INSET_OFFSET);
+ int w = UpdatableInset::getMaxWidth(pain, inset);
+ if (w < 0)
+ return w;
+ return w - (2*TEXT_TO_INSET_OFFSET);
}
}
-void InsetText::deleteLyXText(BufferView * bv)
+void InsetText::deleteLyXText(BufferView * bv) const
{
cache.erase(bv);
/// then remove all LyXText in text-insets
///
void Write(Buffer const *, std::ostream &) const;
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const & f) const;
+ int width(BufferView *, LyXFont const & f) const;
///
int textWidth(Painter &) const;
///
// LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
///
LyXText * getLyXText(BufferView *) const;
- void deleteLyXText(BufferView *);
+ void deleteLyXText(BufferView *) const;
LyXParagraph * par;
///
///
mutable bool locked;
///
- int insetAscent;
- int insetDescent;
- int insetWidth;
+ mutable int insetAscent;
+ mutable int insetDescent;
+ mutable int insetWidth;
mutable int last_width;
mutable int last_height;
mutable int top_y;
///
virtual ~Inset() {}
///
- virtual int ascent(Painter &, LyXFont const &) const = 0;
+ virtual int ascent(BufferView *, LyXFont const &) const = 0;
///
- virtual int descent(Painter &, LyXFont const &) const = 0;
+ virtual int descent(BufferView *, LyXFont const &) const = 0;
///
- virtual int width(Painter &, LyXFont const &) const = 0;
+ virtual int width(BufferView *, LyXFont const &) const = 0;
///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x, bool cleared) const = 0;
txt->cursor.par(),
txt->cursor.pos());
tmpinset->Edit(owner->view(),
- tmpinset->x() + tmpinset->width(owner->view()->painter(),font),
- tmpinset->descent(owner->view()->painter(),font),
+ tmpinset->x() +
+ tmpinset->width(owner->view(),font),
+ tmpinset->descent(owner->view(),font),
0);
break;
}
}
-int InsetFormula::ascent(Painter &, LyXFont const &) const
+int InsetFormula::ascent(BufferView *, LyXFont const &) const
{
return par->Ascent() + ((disp_flag) ? 8 : 1);
}
-int InsetFormula::descent(Painter &, LyXFont const &) const
+int InsetFormula::descent(BufferView *, LyXFont const &) const
{
return par->Descent() + ((disp_flag) ? 8 : 1);
}
-int InsetFormula::width(Painter &, LyXFont const & f) const
+int InsetFormula::width(BufferView *, LyXFont const & f) const
{
lfont_size = f.size();
par->Metrics();
} else {
par->draw(pain, int(x), baseline);
}
- x += float(width(pain, font));
+ x += float(width(bv, font));
if (par->GetType() == LM_OT_PARN || par->GetType() == LM_OT_MPARN) {
LyXFont wfont = WhichFont(LM_TC_BF, par->size);
///
~InsetFormula();
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *,LyXFont const &, int, float &, bool) const;
///
}
-int InsetFormulaMacro::ascent(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::ascent(BufferView * pain, LyXFont const & f) const
{
if (opened) {
tmacro->update();
}
-int InsetFormulaMacro::descent(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::descent(BufferView * pain, LyXFont const & f) const
{
if (opened) {
tmacro->update();
}
-int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const
+int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
{
if (opened) {
tmacro->update();
- return InsetFormula::width(pain, f);
+ return InsetFormula::width(bv, f);
}
string ilabel(_("Macro: "));
ilabel += name;
} else {
font.setColor(LColor::math);
- int y = baseline - ascent(pain, font) + 1;
- int w = width(pain, font) - 2;
- int h = (ascent(pain, font) + descent(pain, font) - 2);
+ int y = baseline - ascent(bv, font) + 1;
+ int w = width(bv, font) - 2;
+ int h = (ascent(bv, font) + descent(bv, font) - 2);
pain.fillRectangle(int(x), y, w, h, LColor::mathbg);
string s(_("Macro: "));
s += name;
pain.text(int(x + 2), baseline, s, font);
- x += width(pain, font) - 1;
+ x += width(bv, font) - 1;
}
}
///
~InsetFormulaMacro();
///
- int ascent(Painter &, LyXFont const &) const;
+ int ascent(BufferView *, LyXFont const &) const;
///
- int descent(Painter &, LyXFont const &) const;
+ int descent(BufferView *, LyXFont const &) const;
///
- int width(Painter &, LyXFont const &) const;
+ int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *,LyXFont const &, int, float &, bool) const;
///
// this is a bad idea, but how can LyXParagraph find its buffer to get
// parameters? (JMarc)
extern BufferView * current_view;
-extern string bibitemWidest(Painter &);
+extern string bibitemWidest(BufferView *);
// this is a minibuffer
static char minibuffer_char;
} else if (style.labeltype == LABEL_BIBLIO) {
// ale970405
os << "\\begin{" << style.latexname() << "}{"
- << bibitemWidest(current_view->painter())
+ << bibitemWidest(current_view)
<< "}\n";
} else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
#ifdef FANCY_FOOTNOTE_CODE
long y = max(text->refresh_y - long(text->first), 0L);
int height;
if (text->inset_owner)
- height = text->inset_owner->ascent(owner.owner()->painter(),
- text->real_current_font)
- + text->inset_owner->descent(owner.owner()->painter(),
+ height = text->inset_owner->ascent(owner.owner(),
+ text->real_current_font)
+ + text->inset_owner->descent(owner.owner(),
text->real_current_font);
else
height = owner.height();
using std::pair;
static const int LYX_PAPER_MARGIN = 20;
-extern int bibitemMaxWidth(Painter &, LyXFont const &);
+extern int bibitemMaxWidth(BufferView *, LyXFont const &);
int LyXText::workWidth(BufferView * bview) const
Inset * tmpinset = par->GetInset(pos);
if (tmpinset) {
tmpinset->update(bview, font);
- return tmpinset->width(bview->painter(), font);
+ return tmpinset->width(bview, font);
} else
return 0;
.defaultfont());
else if (layout.labeltype == LABEL_BIBLIO) {
// ale970405 Right width for bibitems
- x += bibitemMaxWidth(bview->painter(),
- textclasslist
+ x += bibitemMaxWidth(bview,textclasslist
.TextClass(bview->buffer()->params
.textclass)
.defaultfont());
tmpinset = row_ptr->par()->GetInset(pos);
if (tmpinset) {
tmpinset->update(bview, tmpfont);
- asc = tmpinset->ascent(bview->painter(), tmpfont);
- desc = tmpinset->descent(bview->painter(), tmpfont);
- maxwidth += tmpinset->width(bview->painter(), tmpfont);
+ asc = tmpinset->ascent(bview, tmpfont);
+ desc = tmpinset->descent(bview, tmpfont);
+ maxwidth += tmpinset->width(bview, tmpfont);
maxasc = max(maxasc, asc);
maxdesc = max(maxdesc, desc);
}
} else if (clear_area) {
int w;
if (inset_owner)
- w = inset_owner->width(bview->painter(), font);
+ w = inset_owner->width(bview, font);
else
w = ww;
pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
} else if (inset != 0) {
- int h = row_ptr->baseline() - inset->ascent(pain, font);
+ int h = row_ptr->baseline() - inset->ascent(bview, font);
if (h > 0) {
int w;
if (inset_owner)
- w = inset_owner->width(bview->painter(), font);
+ w = inset_owner->width(bview, font);
else
w = ww;
pain.fillRectangle(x_offset, y_offset, w, h);
+ lyxfont::width(layout.labelsep, font);
else
tmpx = x - lyxfont::width(layout.labelsep, font)
- - row_ptr->par()->bibkey->width(bview->painter(), font);
+ - row_ptr->par()->bibkey->width(bview, font);
row_ptr->par()->bibkey->draw(bview, font,
y_offset + row_ptr->baseline(),
tmpx, clear_area);