+2000-06-26 Juergen Vigna <jug@sad.it>
+
+ * src/lyxrow.C (width): added this functions and variable.
+
+ * src/insets/insetcite.C (create_form_citation_form): some Gravity
+ changes.
+
+ * src/text.C (SetHeightOfRow): fixed calcualting of width.
+
2000-06-26 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/BufferView.h: add a magic "friend" declaration to please
lcol: FL_BLACK
label: @4->
shortcut:
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
-name: addBtn
+name: bibBrsr
callback: citation_cb
-argument: InsetCitation::ADD
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 40 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
lcol: FL_BLACK
label: @9+
shortcut:
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
-name: delBtn
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 90 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
callback: citation_cb
-argument: InsetCitation::DELETE
+argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
lcol: FL_BLACK
label: @8->
shortcut:
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
-name: upBtn
+name: bibBrsr
callback: citation_cb
-argument: InsetCitation::UP
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 140 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
lcol: FL_BLACK
label: @2->
shortcut:
-resize: FL_RESIZE_NONE
+resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
-name: downBtn
+name: bibBrsr
+callback: citation_cb
+argument: InsetCitation::BIBBRSR
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 190 40 40
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Button
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_South FL_South
+name: bibBrsr
callback: citation_cb
-argument: InsetCitation::DOWN
+argument: InsetCitation::BIBBRSR
--------------------
class: FL_BROWSER
callback:
argument:
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 100 620 250 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Text before
-shortcut:
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: textBefore
-callback:
-argument:
-
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 100 660 250 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Text after
-shortcut:
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: textAftr
-callback:
-argument:
-
---------------------
-class: FL_BUTTON
-type: RETURN_BUTTON
-box: 190 730 110 40
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: OK
-shortcut: ^M
-resize: FL_RESIZE_ALL
-gravity: FL_SouthEast FL_SouthEast
-name: ok
-callback: citation_cb
-argument: InsetCitation::OK
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 310 730 110 40
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Cancel
-shortcut: ^[
-resize: FL_RESIZE_ALL
-gravity: FL_SouthEast FL_SouthEast
-name: cancel
-callback: citation_cb
-argument: InsetCitation::CANCEL
-
==============================
-create_the_forms
+--------------------
void UpdatableInset::draw(BufferView *, LyXFont const &,
- int /* baseline */, float & x) const
+ int /* baseline */, float & x, bool/*cleared*/) const
{
if (scx) x += float(scx);
// ATTENTION: don't do the following here!!!
fdui->addBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,40,40,40,"@4->");
+ fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::ADD);
fdui->delBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,90,40,40,"@9+");
+ fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::DELETE);
fdui->upBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,140,40,40,"@8->");
+ fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::UP);
fdui->downBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,190,40,40,"@2->");
+ fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::DOWN);
fdui->textAftr = obj =
fl_add_input(FL_NORMAL_INPUT,100,660,250,30,_("Text after"));
+ fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
fl_set_object_resize(obj, FL_RESIZE_X);
fdui->ok = obj =
fl_set_form_size( form->form, 430, formHeight );
// No resizing is alowed in the y-direction
- fl_set_form_minsize( form->form, 300, formHeight );
+ fl_set_form_minsize( form->form, 430, formHeight );
fl_set_form_maxsize( form->form, 1000, formHeight );
int ypos = 0;
autocollapse = true;
autoBreakRows = true;
framecolor = LColor::footnoteframe;
- widthOffset = 6; // 2+2 (behind+back), 1+1 (frame)
+ widthOffset = 2 * TEXT_TO_INSET_OFFSET + 2; // 1+1 (frame)
button_length = button_top_y = button_bottom_y = 0;
setInsetName("Collapsable");
}
draw_collapsed(pain, f, baseline, x);
x -= TEXT_TO_INSET_OFFSET;
- int w = InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET;
+ int w = InsetText::width(pain, f) + (2 * TEXT_TO_INSET_OFFSET);
int h = ascent(pain,f) + descent(pain, f);
int save_x = static_cast<int>(x);
x += TEXT_TO_INSET_OFFSET;
- drawTextXOffset = int(x) - top_x;
InsetText::draw(bv, f, baseline, x, cleared);
pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
}
return getMaxWidth(pain, inset) -
width_collapsed(pain, labelfont) - widthOffset;
}
+
+void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool dodraw)
+{
+ drawTextXOffset = width_collapsed(bv->painter(), font);
+ InsetText::update(bv, font, dodraw);
+}
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
+ void update(BufferView *, LyXFont const &, bool =false);
+ ///
void Edit(BufferView *, int, int, unsigned int);
///
EDITABLE Editable() const;
bool InsertInsetAllowed(Inset * inset) const;
///
LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
- ///
};
#endif
int nx;
float cx;
- UpdatableInset::draw(bv,font,baseline,x);
+ UpdatableInset::draw(bv,font,baseline,x,cleared);
if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
need_update = FULL;
top_x = int(x);
void InsetText::init(InsetText const * ins)
{
+ top_y = last_width = last_height = 0;
insetAscent = insetDescent = insetWidth = 0;
the_locking_inset = 0;
cursor_visible = false;
{
Painter & pain = bv->painter();
- xpos = x;
- UpdatableInset::draw(bv, f, baseline, x);
-
- if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) ||
- (top_baseline!=baseline))) {
+ if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
+ (top_baseline!=baseline))) {
+#if 0
+ // && locked && ((need_update==FULL) || (top_x!=int(x)) ||
+ // (top_baseline!=baseline))) {
need_update = NONE;
top_x = int(x);
top_baseline = baseline;
width(pain, f), ascent(pain,f)+descent(pain, f),
frame_color);
return;
+#else
+ pain.fillRectangle(top_x+drawTextXOffset, top_y, last_width,
+ last_height);
+ need_update = FULL;
+#endif
}
+
+ if (!cleared && (need_update == NONE))
+ return;
+
+ xpos = x;
+ UpdatableInset::draw(bv, f, baseline, x, cleared);
+
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);
if (the_locking_inset && (cpos(bv) == inset_pos)) {
inset_x = cx(bv) - top_x + drawTextXOffset;
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
TEXT_TO_INSET_OFFSET;
- insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) +
+ insetWidth = max(textWidth(bv->painter()),
+ static_cast<int>(TEXT(bv)->width)) +
(2 * TEXT_TO_INSET_OFFSET);
}
the_locking_inset = 0;
}
HideInsetCursor(bv);
- lyxerr[Debug::INSETS] << "InsetText::InsetUnlock(" << this <<
- ")" << endl;
no_selection = false;
locked = false;
TEXT(bv)->selection = 0;
- UpdateLocal(bv, FULL, false);
+ UpdateLocal(bv, CURSOR_PAR, false);
bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
}
return false;
if (the_locking_inset == inset) {
the_locking_inset->InsetUnlock(bv);
+ TEXT(bv)->UpdateInset(bv, inset);
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
+ UpdateLocal(bv, FULL, false);
return true;
}
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
- lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
- ")" << endl;
- UpdateLocal(bv, FULL, false);
+// UpdateLocal(bv, FULL, false);
+ TEXT(bv)->UpdateInset(bv, inset);
if (cpos(bv) == inset_pos) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
- the_locking_inset->ToggleInsetCursor(bv);
- UpdateLocal(bv, FULL, false);
- the_locking_inset->ToggleInsetCursor(bv);
+ UpdateLocal(bv, CURSOR_PAR, false);
return result;
} else if (result == FINISHED) {
switch(action) {
case -1:
case LFUN_RIGHT:
- moveRight(bv);
-// TEXT(bv)->cursor.pos(inset_pos + 1);
-// resetPos(bv->painter());
+ moveRight(bv, false);
break;
case LFUN_DOWN:
moveDown(bv);
int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset) const
{
- return getMaxWidth(pain, inset) - 4; // 2+2 width of eventual border
+ return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
}
void InsetText::SetParagraphData(LyXParagraph *p)
int insetAscent;
int insetDescent;
int insetWidth;
+ mutable int last_width;
+ mutable int last_height;
+ mutable int top_y;
///
int inset_pos;
///
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual void draw(BufferView *, LyXFont const &,
- int baseline, float & x) const;
+ int baseline, float & x, bool cleared) const;
///
virtual void SetFont(BufferView *, LyXFont const &,
bool toggleall = false);
Row::Row()
- : par_(0), pos_(0), fill_(0), height_(0),
+ : par_(0), pos_(0), fill_(0), height_(0), width_(0),
ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
{}
}
+void Row::width(unsigned int w)
+{
+ width_ = w;
+}
+
+
+unsigned int Row::width() const
+{
+ return width_;
+}
+
+
void Row::ascent_of_text(unsigned short a)
{
ascent_of_text_ = a;
///
unsigned short height() const;
///
+ void width(unsigned int w);
+ ///
+ unsigned int width() const;
+ ///
void ascent_of_text(unsigned short a);
///
unsigned short ascent_of_text() const;
///
unsigned short height_;
///
+ unsigned int width_;
+ ///
unsigned short ascent_of_text_;
///
unsigned int baseline_;
mutable int number_of_rows;
///
mutable long height;
- mutable int width;
+ mutable unsigned int width;
/// the current font settings
mutable LyXFont current_font;
/// the current font
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
- width = maxwidth;
+ float x, dummy;
+ PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy);
+ row_ptr->width(maxwidth+x);
+ if (inset_owner) {
+ Row * r = firstrow;
+ width = 0;
+ while(r) {
+ if (r->width() > width)
+ width = r->width();
+ r = r->next();
+ }
+ }
}
number_of_rows = 0;
refresh_y = 0;
height = 0;
- width = -1;
+ width = 0;
first = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position