+2000-10-03 Juergen Vigna <jug@sad.it>
+
+ * various files: changed use of BufferView::the_locking_inset.
+
+ * src/BufferView2.C (theLockingInset):
+ (theLockingInset): new functions.
+
+ * src/BufferView.h: removed the_locking_inset.
+
+ * src/lyxtext.h: added the_locking_inset
+
+ * src/BufferView_pimpl.C (checkInsetHit): y_tmp form uint to int.
+
+ * src/insets/lyxinset.h: added bool to ShowInsetCursor definition.
+
2000-10-02 Angus Leeming <a.leeming@ic.ac.uk>
* src/mathed/formula.C (IsMacro): declared but not referenced; removed.
: pimpl_(new Pimpl(this, o, xpos, ypos, width, height))
{
text = 0;
- the_locking_inset = 0;
inset_slept = false;
}
///
int workWidth() const;
///
- UpdatableInset * the_locking_inset;
+ UpdatableInset * theLockingInset() const;
+ void theLockingInset(UpdatableInset const * inset);
///
void updateInset(Inset * inset, bool mark_dirty);
///
{
// if we are in a locking inset we should try to insert the
// inset there otherwise this is a illegal function now
- if (the_locking_inset) {
- if (the_locking_inset->InsertInsetAllowed(inset))
- return the_locking_inset->InsertInset(this, inset);
+ if (theLockingInset()) {
+ if (theLockingInset()->InsertInsetAllowed(inset))
+ return theLockingInset()->InsertInset(this, inset);
return false;
}
void BufferView::menuRedo()
{
- if (the_locking_inset) {
+ if (theLockingInset()) {
owner()->getMiniBuffer()->Set(_("Redo not yet supported in math mode"));
return;
}
bool BufferView::lockInset(UpdatableInset * inset)
{
- if (!the_locking_inset && inset) {
- the_locking_inset = inset;
+ if (!theLockingInset() && inset) {
+ theLockingInset(inset);
return true;
} else if (inset) {
- return the_locking_inset->LockInsetInInset(this, inset);
+ return theLockingInset()->LockInsetInInset(this, inset);
}
return false;
}
void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
{
- if (the_locking_inset && available()) {
+ if (theLockingInset() && available()) {
LyXCursor cursor = text->cursor;
if ((cursor.pos() - 1 >= 0) &&
(cursor.par()->GetChar(cursor.pos() - 1) ==
LyXParagraph::META_INSET) &&
(cursor.par()->GetInset(cursor.pos() - 1) ==
- the_locking_inset->GetLockingInset()))
+ theLockingInset()->GetLockingInset()))
text->SetCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
- y += cursor.y() + the_locking_inset->InsetInInsetY();
+ y += cursor.y() + theLockingInset()->InsetInInsetY();
pimpl_->screen_->ShowManualCursor(text, x, y, asc, desc,
LyXScreen::BAR_SHAPE);
}
void BufferView::hideLockedInsetCursor()
{
- if (the_locking_inset && available()) {
+ if (theLockingInset() && available()) {
pimpl_->screen_->HideCursor();
}
}
void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
{
- if (the_locking_inset && available()){
- y += text->cursor.y() + the_locking_inset->InsetInInsetY();
+ if (theLockingInset() && available()){
+ y += text->cursor.y() + theLockingInset()->InsetInInsetY();
if (pimpl_->screen_->FitManualCursor(text, x, y, asc, desc))
updateScrollbar();
}
int BufferView::unlockInset(UpdatableInset * inset)
{
- if (inset && the_locking_inset == inset) {
+ if (inset && theLockingInset() == inset) {
inset->InsetUnlock(this);
- the_locking_inset = 0;
+ theLockingInset(0);
text->FinishUndo();
return 0;
- } else if (inset && the_locking_inset &&
- the_locking_inset->UnlockInsetInInset(this, inset)) {
+ } else if (inset && theLockingInset() &&
+ theLockingInset()->UnlockInsetInInset(this, inset)) {
text->FinishUndo();
return 0;
}
void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
{
- if (!the_locking_inset)
+ if (!theLockingInset())
return; // shouldn't happen
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
return;
// first check for locking insets
- if (the_locking_inset) {
- if (the_locking_inset == inset) {
+ if (theLockingInset()) {
+ if (theLockingInset() == inset) {
if (text->UpdateInset(this, inset)){
update();
if (mark_dirty){
updateScrollbar();
return;
}
- } else if (the_locking_inset->UpdateInsetInInset(this,inset)) {
- if (text->UpdateInset(this, the_locking_inset)) {
+ } else if (theLockingInset()->UpdateInsetInInset(this,inset)) {
+ if (text->UpdateInset(this, theLockingInset())) {
update();
if (mark_dirty){
if (buffer()->isLyxClean())
text->SetCursorIntern(this, cursor.par(), cursor.pos());
return flag;
}
+
+
+UpdatableInset * BufferView::theLockingInset() const
+{
+ return text->the_locking_inset;
+}
+
+
+void BufferView::theLockingInset(UpdatableInset const * inset)
+{
+ text->the_locking_inset = inset;
+}
LyXText * vbt = bv_->text;
unsigned int height = vbt->DefaultHeight();
- if (vbt->cursor.y() < bv_->text->first + height) {
+ if (vbt->cursor.y() < (int)(bv_->text->first + height)) {
vbt->SetCursorFromCoordinates(bv_, 0,
bv_->text->first +
height);
} else if (vbt->cursor.y() >
- bv_->text->first + workarea_->height() - height) {
+ (int)(bv_->text->first+workarea_->height()-height))
+ {
vbt->SetCursorFromCoordinates(bv_, 0,
bv_->text->first +
workarea_->height() -
if (buffer_ == 0 || !screen_) return;
// Check for inset locking
- if (bv_->the_locking_inset) {
+ if (bv_->theLockingInset()) {
LyXCursor cursor = bv_->text->cursor;
- bv_->the_locking_inset->
+ bv_->theLockingInset()->
InsetMotionNotify(bv_,
x - cursor.x() -
- bv_->the_locking_inset->scroll(),
+ bv_->theLockingInset()->scroll(),
y - cursor.y() + bv_->text->first,
state);
return;
}
}
- if (bv_->the_locking_inset) {
+ if (bv_->theLockingInset()) {
// We are in inset locking mode
/* Check whether the inset was hit. If not reset mode,
otherwise give the event to the inset */
- if (inset_hit == bv_->the_locking_inset) {
- bv_->the_locking_inset->
+ if (inset_hit == bv_->theLockingInset()) {
+ bv_->theLockingInset()->
InsetButtonPress(bv_,
xpos, ypos,
button);
return;
} else {
- bv_->unlockInset(bv_->the_locking_inset);
+ bv_->unlockInset(bv_->theLockingInset());
}
}
void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
{
// select a word
- if (buffer_ && !bv_->the_locking_inset) {
+ if (buffer_ && !bv_->theLockingInset()) {
if (screen_ && button == 1) {
screen_->HideCursor();
screen_->ToggleSelection(bv_->text);
void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
{
// select a line
- if (buffer_ && screen_ && !bv_->the_locking_inset && (button == 1)) {
+ if (buffer_ && screen_ && !bv_->theLockingInset() && (button == 1)) {
screen_->HideCursor();
screen_->ToggleSelection(bv_->text);
bv_->text->CursorHome(bv_);
// inset, inset_hit is 0, and inset_x == x, inset_y == y.
Inset * inset_hit = checkInsetHit(bv_->text, x, y, button);
- if (bv_->the_locking_inset) {
+ if (bv_->theLockingInset()) {
// We are in inset locking mode.
/* LyX does a kind of work-area grabbing for insets.
Only a ButtonPress Event outside the inset will
force a InsetUnlock. */
- bv_->the_locking_inset->
+ bv_->theLockingInset()->
InsetButtonRelease(bv_, x, y, button);
return;
}
if (!screen_)
return 0;
- unsigned int y_tmp = y + text->first;
+ int y_tmp = y + text->first;
LyXCursor cursor;
text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
&& 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))
+ if (move_cursor && (tmpinset != bv_->theLockingInset()))
#endif
text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true);
x = x - start_x;
goto set_timer_and_return;
}
- if (!bv_->the_locking_inset) {
+ if (!bv_->theLockingInset()) {
screen_->CursorToggle(bv_->text);
} else {
- bv_->the_locking_inset->
- ToggleInsetCursor(bv_);
+ bv_->theLockingInset()->ToggleInsetCursor(bv_);
}
set_timer_and_return:
void BufferView::Pimpl::insetSleep()
{
- if (bv_->the_locking_inset && !bv_->inset_slept) {
- bv_->the_locking_inset->GetCursorPos(bv_, bv_->slx, bv_->sly);
- bv_->the_locking_inset->InsetUnlock(bv_);
+ if (bv_->theLockingInset() && !bv_->inset_slept) {
+ bv_->theLockingInset()->GetCursorPos(bv_, bv_->slx, bv_->sly);
+ bv_->theLockingInset()->InsetUnlock(bv_);
bv_->inset_slept = true;
}
}
void BufferView::Pimpl::insetWakeup()
{
- if (bv_->the_locking_inset && bv_->inset_slept) {
- bv_->the_locking_inset->Edit(bv_, bv_->slx, bv_->sly, 0);
+ if (bv_->theLockingInset() && bv_->inset_slept) {
+ bv_->theLockingInset()->Edit(bv_, bv_->slx, bv_->sly, 0);
bv_->inset_slept = false;
}
}
void BufferView::Pimpl::insetUnlock()
{
- if (bv_->the_locking_inset) {
- if (!bv_->inset_slept) bv_->the_locking_inset->InsetUnlock(bv_);
- bv_->the_locking_inset = 0;
+ if (bv_->theLockingInset()) {
+ if (!bv_->inset_slept)
+ bv_->theLockingInset()->InsetUnlock(bv_);
+ bv_->theLockingInset(0);
bv_->text->FinishUndo();
bv_->inset_slept = false;
}
void BufferView::Pimpl::center()
{
beforeChange();
- if (bv_->text->cursor.y() > workarea_->height() / 2) {
+ if (bv_->text->cursor.y() > (int)(workarea_->height() / 2)) {
screen_->Draw(bv_->text, bv_->text->cursor.y() - workarea_->height() / 2);
} else {
screen_->Draw(bv_->text, 0);
for(BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if ((*it)->getUser()
- && (*it)->getUser()->the_locking_inset == inset) {
+ && (*it)->getUser()->theLockingInset() == inset) {
(*it)->getUser()->insetUnlock();
return 0;
}
// font. (Asger)
LyXText *text = 0;
- if (bv->the_locking_inset)
- text = bv->the_locking_inset->getLyXText(bv);
+ if (bv->theLockingInset())
+ text = bv->theLockingInset()->getLyXText(bv);
if (!text)
text = bv->text;
if (bv->available()) {
bv->hideCursor();
bv->update(BufferView::SELECT|BufferView::FITCUR);
- if (bv->the_locking_inset)
- bv->the_locking_inset->SetFont(bv, font, toggleall);
+ if (bv->theLockingInset())
+ bv->theLockingInset()->SetFont(bv, font, toggleall);
else
bv->text->ToggleFree(bv, font, toggleall);
bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
noindent = fl_get_button(general_->check_noindent);
LyXText * text = 0;
- if (lv_->view()->the_locking_inset)
- text = lv_->view()->the_locking_inset->getLyXText(lv_->view());
+ if (lv_->view()->theLockingInset())
+ text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
if (!text)
text = lv_->view()->text;
text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
Buffer * buf = lv_->view()->buffer();
LyXText * text = 0;
- if (lv_->view()->the_locking_inset)
- text = lv_->view()->the_locking_inset->getLyXText(lv_->view());
+ if (lv_->view()->theLockingInset())
+ text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
if (!text)
text = lv_->view()->text;
}
-void UpdatableInset::ShowInsetCursor(BufferView *)
+void UpdatableInset::ShowInsetCursor(BufferView *, bool)
{
}
the_locking_inset->InsetUnlock(bv);
}
the_locking_inset = 0;
- if (inset_hit && bv->the_locking_inset) {
+ if (inset_hit && bv->theLockingInset()) {
if (ActivateCellInset(bv, x, y, button))
the_locking_inset->InsetButtonPress(bv, x - inset_x,
y - inset_y, button);
the_locking_inset->InsetUnlock(bv);
the_locking_inset = 0;
}
- if (bv->the_locking_inset) {
+ if (bv->theLockingInset()) {
if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) {
UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
inset_x = cx(bv) - top_x + drawTextXOffset;
}
-void InsetText::ShowInsetCursor(BufferView * bv)
+void InsetText::ShowInsetCursor(BufferView * bv, bool show)
{
if (the_locking_inset) {
the_locking_inset->ShowInsetCursor(bv);
int desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
- bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+ if (show)
+ bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
cursor_visible = true;
}
}
///
int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
///
- void ShowInsetCursor(BufferView *);
+ void ShowInsetCursor(BufferView *, bool show=true);
///
void HideInsetCursor(BufferView *);
///
/// may call ToggleLockedInsetCursor
virtual void ToggleInsetCursor(BufferView *);
///
- virtual void ShowInsetCursor(BufferView *);
+ virtual void ShowInsetCursor(BufferView *, bool show=true);
///
virtual void HideInsetCursor(BufferView *);
///
}
// this function should be used always [asierra060396]
- UpdatableInset * tli = owner->view()->the_locking_inset;
+ UpdatableInset * tli = owner->view()->theLockingInset();
if (owner->view()->available() && tli && (keysym == XK_Escape)) {
if (tli == tli->GetLockingInset()) {
owner->view()->unlockInset(tli);
}
// this function should be used always [asierra060396]
- UpdatableInset * tli = owner->view()->the_locking_inset;
+ UpdatableInset * tli = owner->view()->theLockingInset();
if (owner->view()->available() && tli && (keysym_return==XK_Escape)) {
if (tli == tli->GetLockingInset()) {
owner->view()->unlockInset(tli);
case LFUN_LAYOUT_TABULAR:
disable = true;
- if (owner->view()->the_locking_inset) {
- disable = (owner->view()->the_locking_inset->LyxCode() != Inset::TABULAR_CODE) &&
- !owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
+ if (owner->view()->theLockingInset()) {
+ disable = (owner->view()->theLockingInset()->LyxCode() != Inset::TABULAR_CODE) &&
+ !owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
}
break;
case LFUN_TABULAR_FEATURE:
disable = true;
- if (owner->view()->the_locking_inset) {
+ if (owner->view()->theLockingInset()) {
func_status ret = LyXFunc::Disabled;
- if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) {
+ if (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) {
ret = static_cast<InsetTabular *>
- (owner->view()->the_locking_inset)->
+ (owner->view()->theLockingInset())->
getStatus(argument);
- } else if (owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
+ } else if (owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *>
- (owner->view()->the_locking_inset->
+ (owner->view()->theLockingInset()->
GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
getStatus(argument);
}
if (buf) {
func_status box = LyXFunc::ToggleOff;
LyXFont font;
- if (owner->view()->the_locking_inset &&
- owner->view()->the_locking_inset->getLyXText(owner->view()))
- font = owner->view()->the_locking_inset->
+ if (owner->view()->theLockingInset() &&
+ owner->view()->theLockingInset()->getLyXText(owner->view()))
+ font = owner->view()->theLockingInset()->
getLyXText(owner->view())->real_current_font;
else
font = owner->view()->text->real_current_font;
}
}
- if (owner->view()->available() && owner->view()->the_locking_inset) {
- text = owner->view()->the_locking_inset->getLyXText(owner->view());
+ if (owner->view()->available() && owner->view()->theLockingInset()) {
+ text = owner->view()->theLockingInset()->getLyXText(owner->view());
UpdatableInset::RESULT result;
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
(keyseq.length >= -1)))
int slx;
int sly;
UpdatableInset * inset =
- owner->view()->the_locking_inset;
+ owner->view()->theLockingInset();
inset->GetCursorPos(owner->view(), slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuUndo();
int slx;
int sly;
UpdatableInset * inset = owner->view()->
- the_locking_inset;
+ theLockingInset();
inset->GetCursorPos(owner->view(), slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuRedo();
if (inset)
inset->Edit(owner->view(),slx,sly,0);
return string();
- } else if (((result=owner->view()->the_locking_inset->
+ } else if (((result=owner->view()->theLockingInset()->
LocalDispatch(owner->view(), action,
argument)) ==
UpdatableInset::DISPATCHED) ||
break;
case LFUN_LAYOUT_TABULAR:
- if (owner->view()->the_locking_inset) {
- if (owner->view()->the_locking_inset->LyxCode()==Inset::TABULAR_CODE) {
+ if (owner->view()->theLockingInset()) {
+ if (owner->view()->theLockingInset()->LyxCode()==Inset::TABULAR_CODE) {
InsetTabular * inset = static_cast<InsetTabular *>
- (owner->view()->the_locking_inset);
+ (owner->view()->theLockingInset());
inset->OpenLayoutDialog(owner->view());
- } else if (owner->view()->the_locking_inset->
+ } else if (owner->view()->theLockingInset()->
GetFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
InsetTabular * inset = static_cast<InsetTabular *>(
- owner->view()->the_locking_inset->GetFirstLockingInsetOfType(Inset::TABULAR_CODE));
+ owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE));
inset->OpenLayoutDialog(owner->view());
}
}
case LFUN_INSET_CAPTION:
{
// Do we have a locking inset...
- if (owner->view()->the_locking_inset) {
+ if (owner->view()->theLockingInset()) {
lyxerr << "Locking inset code: "
- << static_cast<int>(owner->view()->the_locking_inset->LyxCode());
+ << static_cast<int>(owner->view()->theLockingInset()->LyxCode());
InsetCaption * new_inset = new InsetCaption;
- new_inset->setOwner(owner->view()->the_locking_inset);
+ new_inset->setOwner(owner->view()->theLockingInset());
new_inset->SetAutoBreakRows(true);
new_inset->SetDrawFrame(0, InsetText::LOCKED);
new_inset->SetFrameColor(0, LColor::footnoteframe);
owner->view()->
open_new_inset(new InsetFormula(false));
owner->view()
- ->the_locking_inset
+ ->theLockingInset()
->LocalDispatch(owner->view(),
action,
argument);
BufferView * bv_owner;
///
InsetText * inset_owner;
+ ///
+ UpdatableInset * the_locking_inset;
///
LyXFont const GetFont(Buffer const *, LyXParagraph * par,
}
-void InsetFormula::ShowInsetCursor(BufferView * bv)
+void InsetFormula::ShowInsetCursor(BufferView * bv, bool)
{
if (!cursor_visible) {
if (mathcursor) {
///
void ToggleInsetCursor(BufferView *);
///
- void ShowInsetCursor(BufferView *);
+ void ShowInsetCursor(BufferView *, bool show=true);
///
void HideInsetCursor(BufferView *);
///
('a'<= c && c<= 'z'))) {
string tmp;
tmp = c;
- if (!current_view->the_locking_inset) {
+ if (!current_view->theLockingInset()) {
int greek_kb_flag_save = greek_kb_flag;
InsetFormula * new_inset = new InsetFormula();
current_view->beforeChange();
new_inset->Edit(current_view, 0, 0, 0);
new_inset->LocalDispatch(current_view, LFUN_SELFINSERT, tmp);
if (greek_kb_flag_save < 2)
- current_view->unlockInset(current_view->the_locking_inset);
+ current_view->unlockInset(current_view->theLockingInset());
} else
- if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE)
- static_cast<InsetFormula*>(current_view->the_locking_inset)->LocalDispatch(current_view, LFUN_SELFINSERT, tmp);
+ if (current_view->theLockingInset()->LyxCode() == Inset::MATH_CODE)
+ static_cast<InsetFormula*>(current_view->theLockingInset())->LocalDispatch(current_view, LFUN_SELFINSERT, tmp);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
void math_insert_symbol(string const & s)
{
if (current_view->available()) {
- if (!current_view->the_locking_inset) {
+ if (!current_view->theLockingInset()) {
InsetFormula * new_inset = new InsetFormula();
current_view->beforeChange();
current_view->insertInset(new_inset);
new_inset->Edit(current_view, 0, 0, 0);
new_inset->InsertSymbol(current_view, s);
} else
- if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE)
- static_cast<InsetFormula*>(current_view->the_locking_inset)->InsertSymbol(current_view, s);
+ if (current_view->theLockingInset()->LyxCode() == Inset::MATH_CODE)
+ static_cast<InsetFormula*>(current_view->theLockingInset())->InsertSymbol(current_view, s);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
void LyXText::init()
{
+ the_locking_inset = 0;
firstrow = 0;
lastrow = 0;
number_of_rows = 0;
LyXParagraph::size_type pos,
string const & str) const
{
- if (par) {
- LyXParagraph::size_type i = 0;
- while (pos + i < par->Last()
- && string::size_type(i) < str.length()
- && str[i] == par->GetChar(pos + i)) {
- ++i;
- }
- if (str.length() == string::size_type(i))
- return true;
+ if (!par)
+ return false;
+
+ LyXParagraph::size_type i = 0;
+ while (pos + i < par->Last()
+ && string::size_type(i) < str.length()
+ && str[i] == par->GetChar(pos + i)) {
+ ++i;
}
+ if (str.length() == string::size_type(i))
+ return true;
return false;
}