minipage placement testing

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1807 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-03-22 19:36:21 +00:00
parent 28da50b522
commit 93dda00aac
4 changed files with 92 additions and 23 deletions

View File

@ -2809,7 +2809,8 @@ void linux_doc_line_break(ostream & os, string::size_type & colcount,
// Handle internal paragraph parsing -- layout already processed.
void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, int /*depth*/)
void Buffer::SimpleLinuxDocOnePar(ostream & os,
LyXParagraph * par, int /*depth*/)
{
LyXLayout const & style = textclasslist.Style(params.textclass,
par->GetLayout());
@ -2821,8 +2822,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, int /*depth*
if (style.labeltype == LABEL_MANUAL) {
font_old = style.labelfont;
desc_on = true;
}
else {
} else {
font_old = style.font;
desc_on = false;
}
@ -2843,12 +2843,12 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, int /*depth*
};
char const * tag_name[] = {"tt","sf","bf","it","sl","em"};
stack <int> tag_state;
stack<int> tag_state;
// parsing main loop
for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
bitset < LAST > tag_close;
list <int> tag_open;
bitset<LAST> tag_close;
list<int> tag_open;
LyXFont const font = par->getFont(params, i);
@ -2929,16 +2929,15 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, int /*depth*
if (font.emph() == LyXFont::ON) {
tag_open.push_back(EM);
is_em = true;
}
else if (is_em) {
} else if (is_em) {
tag_close.set(EM);
is_em = false;
}
}
list <int> temp;
while(!tag_state.empty() && tag_close.any()) {
int k=tag_state.top();
list<int> temp;
while (!tag_state.empty() && tag_close.any()) {
int k = tag_state.top();
tag_state.pop();
os << "</" << tag_name[k] << ">";
if (tag_close[k])
@ -2947,13 +2946,13 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, int /*depth*
temp.push_back(k);
}
for(list<int>::const_iterator j = temp.begin();
for (list<int>::const_iterator j = temp.begin();
j != temp.end(); ++j) {
tag_state.push(*j);
os << "<" << tag_name[*j] << ">";
}
for(list<int>::const_iterator j = tag_open.begin();
for (list<int>::const_iterator j = tag_open.begin();
j != tag_open.end(); ++j) {
tag_state.push(*j);
os << "<" << tag_name[*j] << ">";
@ -3027,17 +3026,22 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
niceFile = nice; // this will be used by Insetincludes.
string top_element= textclasslist.LatexnameOfClass(params.textclass);
string top_element = textclasslist.LatexnameOfClass(params.textclass);
vector <string> environment_stack;
vector <string> environment_inner;
vector <string> command_stack;
bool command_flag= false;
int command_depth= 0, command_base= 0, cmd_depth= 0;
bool command_flag = false;
int command_depth = 0;
int command_base = 0;
int cmd_depth = 0;
string item_name, command_name;
string c_depth, c_params, tmps;
string item_name;
string command_name;
string c_depth;
string c_params;
string tmps;
int depth = 0; // paragraph depth
LyXTextClass const & tclass =

View File

@ -183,7 +183,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
if (!cleared && ((inset->need_update == InsetText::FULL) ||
(inset->need_update == InsetText::INIT) ||
(top_x!=int(x)) || (top_baseline!=baseline))) {
(top_x != int(x)) || (top_baseline != baseline))) {
int w = owner() ? width(bv, f) : pain.paperWidth();
int h = ascent(bv, f) + descent(bv, f);
int tx = (needFullRow() && !owner()) ? 0 : int(x);
@ -203,8 +203,21 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
top_x = int(x);
top_baseline = baseline;
#if 0
draw_collapsed(pain, f, baseline, x);
inset->draw(bv, f, baseline, x, cleared);
#else
#warning Jürgen, can you have a look at this? (Lgb)
// the intention is quite clear if you set the positon in a minipage you
// want the minipage drawn according to that. but as you can see the
// cursor is wrongly placed.
draw_collapsed(pain, f,
baseline - ascent(bv, f) + ascent_collapsed(pain, f),
x);
inset->draw(bv, f,
baseline - ascent(bv, f) + ascent_collapsed(pain, f),
x, cleared);
#endif
need_update = NONE;
}

View File

@ -177,6 +177,56 @@ Inset * InsetMinipage::Clone(Buffer const &) const
}
int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
{
lyxerr << "InsetMinipage::ascent" << endl;
if (collapsed)
return ascent_collapsed(bv->painter(), font);
else {
// Take placement into account.
int i = 0;
switch (pos_) {
case top:
i = InsetCollapsable::ascent(bv, font);
break;
case center:
i = (InsetCollapsable::ascent(bv, font)
+ InsetCollapsable::descent(bv, font)) / 2;
break;
case bottom:
i = InsetCollapsable::descent(bv, font);
break;
}
return i;
}
}
int InsetMinipage::descent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
return descent_collapsed(bv->painter(), font);
else {
// Take placement into account.
int i = 0;
switch (pos_) {
case top:
i = InsetCollapsable::descent(bv, font);
break;
case center:
i = (InsetCollapsable::ascent(bv, font)
+ InsetCollapsable::descent(bv, font)) / 2;
break;
case bottom:
i = InsetCollapsable::ascent(bv, font);
break;
}
return i;
}
}
string const InsetMinipage::EditMessage() const
{
return _("Opened Minipage Inset");

View File

@ -4,9 +4,9 @@
*
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
* Copyright 2001 The LyX Team.
*
*======================================================
* ======================================================
*/
#ifndef InsetMinipage_H
@ -49,6 +49,10 @@ public:
///
Inset * Clone(Buffer const &) const;
///
int ascent(BufferView *, LyXFont const &) const;
///
int descent(BufferView *, LyXFont const &) const;
///
Inset::Code LyxCode() const { return Inset::MINIPAGE_CODE; }
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
@ -86,8 +90,6 @@ public:
int getMaxWidth(Painter &, UpdatableInset const *) const;
///
bool needFullRow() const { return false; }
private:
///
Position pos_;