Remove enter/leaveView since core has no right to know when

that happens, and rename wa->height to workHeight() for consistency


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4373 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-06-12 00:51:45 +00:00
parent 92e53dc01b
commit ae11d20ade
10 changed files with 77 additions and 259 deletions

View File

@ -145,10 +145,6 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
workarea().scrollCB.connect(boost::bind(&BufferView::Pimpl::scrollCB, this, _1));
workarea().workAreaExpose
.connect(boost::bind(&BufferView::Pimpl::workAreaExpose, this));
workarea().workAreaEnter
.connect(boost::bind(&BufferView::Pimpl::enterView, this));
workarea().workAreaLeave
.connect(boost::bind(&BufferView::Pimpl::leaveView, this));
workarea().workAreaButtonPress
.connect(boost::bind(&BufferView::Pimpl::workAreaButtonPress, this, _1, _2, _3));
workarea().workAreaButtonRelease
@ -424,7 +420,7 @@ void BufferView::Pimpl::updateScrollbar()
}
long const text_height = bv_->text->height;
long const work_height = workarea().height();
long const work_height = workarea().workHeight();
double const lineh = bv_->text->defaultHeight();
double const slider_size =
@ -474,7 +470,7 @@ void BufferView::Pimpl::scrollCB(double value)
int const height = vbt->defaultHeight();
int const first = static_cast<int>((bv_->text->first_y + height));
int const last = static_cast<int>((bv_->text->first_y + workarea().height() - height));
int const last = static_cast<int>((bv_->text->first_y + workarea().workHeight() - height));
if (vbt->cursor.y() < first)
vbt->setCursorFromCoordinates(bv_, 0, first);
@ -499,11 +495,11 @@ int BufferView::Pimpl::scrollUp(long time)
float add_value = (bv_->text->defaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea().height())
add_value = float(workarea().height() -
if (add_value > workarea().workHeight())
add_value = float(workarea().workHeight() -
bv_->text->defaultHeight());
#else
float add_value = float(workarea().height()) * float(time) / 100;
float add_value = float(workarea().workHeight()) * float(time) / 100;
#endif
value -= add_value;
@ -534,11 +530,11 @@ int BufferView::Pimpl::scrollDown(long time)
float add_value = (bv_->text->defaultHeight()
+ float(time) * float(time) * 0.125);
if (add_value > workarea().height())
add_value = float(workarea().height() -
if (add_value > workarea().workHeight())
add_value = float(workarea().workHeight() -
bv_->text->defaultHeight());
#else
float add_value = float(workarea().height()) * float(time) / 100;
float add_value = float(workarea().workHeight()) * float(time) / 100;
#endif
value += add_value;
@ -607,7 +603,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
#endif
// This is to allow jumping over large insets
if (cursorrow == bv_->text->cursor.row()) {
if (y >= int(workarea().height())) {
if (y >= int(workarea().workHeight())) {
bv_->text->cursorDown(bv_, false);
} else if (y < 0) {
bv_->text->cursorUp(bv_, false);
@ -829,24 +825,6 @@ void BufferView::Pimpl::selectionLost()
}
void BufferView::Pimpl::enterView()
{
if (available()) {
SetXtermCursor(workarea().getWin());
using_xterm_cursor = true;
}
}
void BufferView::Pimpl::leaveView()
{
if (using_xterm_cursor) {
XUndefineCursor(fl_get_display(), workarea().getWin());
using_xterm_cursor = false;
}
}
void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
mouse_button::state button)
{
@ -1045,11 +1023,11 @@ void BufferView::Pimpl::workAreaExpose()
static unsigned int work_area_height;
bool const widthChange = workarea().workWidth() != work_area_width;
bool const heightChange = workarea().height() != work_area_height;
bool const heightChange = workarea().workHeight() != work_area_height;
// update from work area
work_area_width = workarea().workWidth();
work_area_height = workarea().height();
work_area_height = workarea().workHeight();
if (buffer_ != 0) {
if (widthChange) {
// The visible LyXView need a resize
@ -1212,7 +1190,7 @@ void BufferView::Pimpl::cursorPrevious(LyXText * text)
{
if (!text->cursor.row()->previous()) {
if (text->first_y > 0) {
int new_y = bv_->text->first_y - workarea().height();
int new_y = bv_->text->first_y - workarea().workHeight();
screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
updateScrollbar();
}
@ -1232,18 +1210,18 @@ void BufferView::Pimpl::cursorPrevious(LyXText * text)
// as we move the cursor or do something while inside the row (it may
// span several workarea-heights) we'll move to the top again, but this
// is better than just jump down and only display part of the row.
new_y = bv_->text->first_y - workarea().height();
new_y = bv_->text->first_y - workarea().workHeight();
} else {
if (text->inset_owner) {
new_y = bv_->text->cursor.iy()
+ bv_->theLockingInset()->insetInInsetY() + y
+ text->cursor.row()->height()
- workarea().height() + 1;
- workarea().workHeight() + 1;
} else {
new_y = text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
- workarea().height() + 1;
- workarea().workHeight() + 1;
}
}
screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
@ -1264,15 +1242,15 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
if (!text->cursor.row()->next()) {
int y = text->cursor.y() - text->cursor.row()->baseline() +
text->cursor.row()->height();
if (y > int(text->first_y + workarea().height())) {
if (y > int(text->first_y + workarea().workHeight())) {
screen().draw(bv_->text, bv_,
bv_->text->first_y + workarea().height());
bv_->text->first_y + workarea().workHeight());
updateScrollbar();
}
return;
}
int y = text->first_y + workarea().height();
int y = text->first_y + workarea().workHeight();
if (text->inset_owner && !text->first_y) {
y -= (bv_->text->cursor.iy()
- bv_->text->first_y
@ -1281,7 +1259,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
text->getRowNearY(y);
Row * cursorrow = text->cursor.row();
text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea().height());
text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea().workHeight());
finishUndo();
int new_y;
if (cursorrow == bv_->text->cursor.row()) {
@ -1290,7 +1268,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
// as we move the cursor or do something while inside the row (it may
// span several workarea-heights) we'll move to the top again, but this
// is better than just jump down and only display part of the row.
new_y = bv_->text->first_y + workarea().height();
new_y = bv_->text->first_y + workarea().workHeight();
} else {
if (text->inset_owner) {
new_y = bv_->text->cursor.iy()
@ -1305,7 +1283,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->next()->par(),
text->cursor.row()->next()->pos(), false);
if (cur.y() < int(text->first_y + workarea().height())) {
if (cur.y() < int(text->first_y + workarea().workHeight())) {
text->cursorDown(bv_, true);
}
}
@ -1481,8 +1459,8 @@ void BufferView::Pimpl::toggleToggle()
void BufferView::Pimpl::center()
{
beforeChange(bv_->text);
if (bv_->text->cursor.y() > static_cast<int>((workarea().height() / 2))) {
screen().draw(bv_->text, bv_, bv_->text->cursor.y() - workarea().height() / 2);
if (bv_->text->cursor.y() > static_cast<int>((workarea().workHeight() / 2))) {
screen().draw(bv_->text, bv_, bv_->text->cursor.y() - workarea().workHeight() / 2);
} else {
screen().draw(bv_->text, bv_, 0);
}

View File

@ -90,10 +90,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
///
void selectionLost();
///
void enterView();
///
void leaveView();
///
void cursorToggle();
///
void cursorPrevious(LyXText *);

View File

@ -1,3 +1,9 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* BufferView_pimpl.h:
* BufferView_pimpl.C: remove enter/leaveView,
use workHeight()
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* BufferView.h:

View File

@ -1,3 +1,10 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.C:
* Painter.C: use workHeight()
* WorkArea.h: remove confusing duplicate unused code
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.h:

View File

@ -33,7 +33,7 @@ int PainterBase::paperWidth() const
int PainterBase::paperHeight() const
{
return owner.height();
return owner.workHeight();
}

View File

@ -1,169 +1,2 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ======================================================*/
#ifndef WORKAREA_H
#define WORKAREA_H
#if 1
// temporary
#include "frontends/xforms/XWorkArea.h"
#else
#ifdef __GNUG__
#pragma interface
#endif
#include "frontends/Painter.h"
#include FORMS_H_LOCATION
#include <boost/signals/signal0.hpp>
#include <boost/signals/signal1.hpp>
#include <boost/signals/signal2.hpp>
#include <boost/signals/signal3.hpp>
#include <utility>
///
class WorkArea {
public:
///
WorkArea(int xpos, int ypos, int width, int height);
///
~WorkArea();
///
Painter & getPainter() { return painter_; }
///
int workWidth() const { return work_area->w; }
///
unsigned int width() const { return work_area->w + scrollbar->w; }
//unsigned int width() const { return backgroundbox->w + 15; }
///
unsigned int height() const { return work_area->h; }
//unsigned int height() const { return backgroundbox->h; }
///
int xpos() const { return work_area->x; }
//int xpos() const { return backgroundbox->x; }
///
int ypos() const { return work_area->y; }
//int ypos() const { return backgroundbox->y; }
///
void resize(int xpos, int ypos, int width, int height);
///
void redraw() const {
fl_redraw_object(work_area);
fl_redraw_object(scrollbar);
}
///
void setFocus() const;
///
Window getWin() const { return work_area->form->window; }
///
bool hasFocus() const { return work_area->focus; }
///
bool active() const { return work_area->active; }
///
bool belowMouse() const;
///
bool visible() const { return work_area->form->visible; }
///
void greyOut() const;
///
void setScrollbar(double pos, double length_fraction) const;
///
void setScrollbarValue(double y) const {
fl_set_scrollbar_value(scrollbar, y);
}
///
void setScrollbarBounds(double, double) const;
///
void setScrollbarIncrements(double inc) const;
///
double getScrollbarValue() const {
return fl_get_scrollbar_value(scrollbar);
}
///
std::pair<float, float> const getScrollbarBounds() const {
std::pair<float, float> p;
fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
return p;
}
///
Pixmap getPixmap() const { return workareapixmap; }
/// xforms callback
static int work_area_handler(FL_OBJECT *, int event,
FL_Coord, FL_Coord,
int /*key*/, void * xev);
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
/// a selection exists
void haveSelection(bool) const;
///
string const getClipboard() const;
///
void putClipboard(string const &) const;
// Signals
///
boost::signal0<void> workAreaExpose;
///
boost::signal1<void, double> scrollCB;
///
boost::signal2<void, KeySym, unsigned int> workAreaKeyPress;
///
boost::signal3<void, int, int, unsigned int> workAreaButtonPress;
///
boost::signal3<void, int, int, unsigned int> workAreaButtonRelease;
///
boost::signal3<void, int, int, unsigned int> workAreaMotionNotify;
///
boost::signal0<void> workAreaFocus;
///
boost::signal0<void> workAreaUnfocus;
///
boost::signal0<void> workAreaEnter;
///
boost::signal0<void> workAreaLeave;
///
boost::signal3<void, int, int, unsigned int> workAreaDoubleClick;
///
boost::signal3<void, int, int, unsigned int> workAreaTripleClick;
/// emitted when an X client has requested our selection
boost::signal0<void> selectionRequested;
/// emitted when another X client has stolen our selection
boost::signal0<void> selectionLost;
/// handles SelectionRequest X Event, to fill the clipboard
int event_cb(XEvent * xev);
private:
///
void createPixmap(int, int);
///
FL_OBJECT * backgroundbox;
///
FL_OBJECT * work_area;
///
FL_OBJECT * scrollbar;
///
mutable FL_OBJECT * splash_;
///
mutable FL_OBJECT * splash_text_;
/// The pixmap overlay on the workarea
Pixmap workareapixmap;
///
Painter painter_;
/// if we call redraw with true needed for locking-insets
bool screen_cleared;
};
#endif
#endif

View File

@ -105,8 +105,8 @@ void LScreen::setCursorColor()
void LScreen::redraw(LyXText * text, BufferView * bv)
{
drawFromTo(text, bv, 0, owner.height(), 0, 0, text == bv->text);
expose(0, 0, owner.workWidth(), owner.height());
drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, text == bv->text);
expose(0, 0, owner.workWidth(), owner.workHeight());
if (cursor_visible) {
cursor_visible = false;
bv->showCursor();
@ -180,7 +180,7 @@ void LScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
int const y = y_text - text->first_y + y_offset;
if (((y + row->height()) > 0) &&
((y - row->height()) <= static_cast<int>(owner.height()))) {
((y - row->height()) <= static_cast<int>(owner.workHeight()))) {
// ok there is something visible
text->getVisibleRow(bv, y, x_offset, row, y + text->first_y);
}
@ -199,8 +199,8 @@ void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
text->first_y = y;
// is any optimiziation possible?
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height())
if ((y - old_first) < owner.workHeight()
&& (old_first - y) < owner.workHeight())
{
if (text->first_y < old_first) {
drawFromTo(text, bv, 0,
@ -212,7 +212,7 @@ void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
owner.xpos(),
owner.ypos(),
owner.workWidth(),
owner.height() - old_first + text->first_y,
owner.workHeight() - old_first + text->first_y,
owner.xpos(),
owner.ypos() + old_first - text->first_y
);
@ -222,8 +222,8 @@ void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
old_first - text->first_y);
} else {
drawFromTo(text, bv,
owner.height() + old_first - text->first_y,
owner.height(), 0, 0, internal);
owner.workHeight() + old_first - text->first_y,
owner.workHeight(), 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
@ -231,17 +231,17 @@ void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
owner.xpos(),
owner.ypos() + text->first_y - old_first,
owner.workWidth(),
owner.height() + old_first - text->first_y,
owner.workHeight() + old_first - text->first_y,
owner.xpos(),
owner.ypos());
// expose the area drawn
expose(0, owner.height() + old_first - text->first_y,
expose(0, owner.workHeight() + old_first - text->first_y,
owner.workWidth(), text->first_y - old_first);
}
} else {
// make a dumb new-draw
drawFromTo(text, bv, 0, owner.height(), 0, 0, internal);
expose(0, 0, owner.workWidth(), owner.height());
drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, internal);
expose(0, 0, owner.workWidth(), owner.workHeight());
}
}
@ -270,11 +270,11 @@ bool LScreen::fitManualCursor(LyXText * text, BufferView * bv,
{
int newtop = text->first_y;
if (y + desc - text->first_y >= static_cast<int>(owner.height()))
newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!!
if (y + desc - text->first_y >= static_cast<int>(owner.workHeight()))
newtop = y - 3 * owner.workHeight() / 4; // the scroll region must be so big!!
else if (y - asc < text->first_y
&& text->first_y > 0) {
newtop = y - owner.height() / 4;
newtop = y - owner.workHeight() / 4;
}
newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
@ -296,7 +296,7 @@ void LScreen::showManualCursor(LyXText const * text, int x, int y,
int const y1 = max(y - text->first_y - asc, 0);
int const y_tmp = min(y - text->first_y + desc,
static_cast<int>(owner.height()));
static_cast<int>(owner.workHeight()));
// Secure against very strange situations
int const y2 = max(y_tmp, y1);
@ -306,7 +306,7 @@ void LScreen::showManualCursor(LyXText const * text, int x, int y,
cursor_pixmap = 0;
}
if (y2 > 0 && y1 < int(owner.height())) {
if (y2 > 0 && y1 < int(owner.workHeight())) {
cursor_pixmap_h = y2 - y1 + 1;
cursor_pixmap_y = y1;
@ -406,26 +406,26 @@ unsigned int LScreen::topCursorVisible(LyXText const * text)
return max(newtop, 0);
if (text->cursor.y() - row->baseline() + row->height()
- text->first_y >= owner.height()) {
if (row->height() < owner.height()
&& row->height() > owner.height() / 4) {
- text->first_y >= owner.workHeight()) {
if (row->height() < owner.workHeight()
&& row->height() > owner.workHeight() / 4) {
newtop = text->cursor.y()
+ row->height()
- row->baseline() - owner.height();
- row->baseline() - owner.workHeight();
} else {
// scroll down
newtop = text->cursor.y()
- owner.height() / 2; /* the scroll region must be so big!! */
- owner.workHeight() / 2; /* the scroll region must be so big!! */
}
} else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
text->first_y && text->first_y > 0) {
if (row->height() < owner.height()
&& row->height() > owner.height() / 4) {
if (row->height() < owner.workHeight()
&& row->height() > owner.workHeight() / 4) {
newtop = text->cursor.y() - row->baseline();
} else {
// scroll up
newtop = text->cursor.y() - owner.height() / 2;
newtop = text->cursor.y() - owner.workHeight() / 2;
newtop = min(newtop, text->first_y);
}
}
@ -456,13 +456,13 @@ void LScreen::update(LyXText * text, BufferView * bv,
case LyXText::NEED_MORE_REFRESH:
{
int const y = max(int(text->refresh_y - text->first_y), 0);
drawFromTo(text, bv, y, owner.height(), y_offset, x_offset);
drawFromTo(text, bv, y, owner.workHeight(), y_offset, x_offset);
text->refresh_y = 0;
// otherwise this is called ONLY from BufferView_pimpl(update)
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
expose(0, y, owner.workWidth(), owner.height() - y);
expose(0, y, owner.workWidth(), owner.workHeight() - y);
}
break;
case LyXText::NEED_VERY_LITTLE_REFRESH:
@ -502,12 +502,12 @@ void LScreen::toggleSelection(LyXText * text, BufferView * bv,
- text->selection.end.row()->baseline()
+ text->selection.end.row()->height()),
text->first_y),
static_cast<int>(text->first_y + owner.height()));
static_cast<int>(text->first_y + owner.workHeight()));
int const top = min(
max(static_cast<int>(text->selection.start.y() -
text->selection.start.row()->baseline()),
text->first_y),
static_cast<int>(text->first_y + owner.height()));
static_cast<int>(text->first_y + owner.workHeight()));
if (kill_selection)
text->selection.set(false);
@ -534,9 +534,9 @@ void LScreen::toggleToggle(LyXText * text, BufferView * bv,
int const offset = y_offset < 0 ? y_offset : 0;
int const bottom = min(max(bottom_tmp, text->first_y),
static_cast<int>(text->first_y + owner.height()))-offset;
static_cast<int>(text->first_y + owner.workHeight()))-offset;
int const top = min(max(top_tmp, text->first_y),
static_cast<int>(text->first_y + owner.height()))-offset;
static_cast<int>(text->first_y + owner.workHeight()))-offset;
drawFromTo(text, bv, top - text->first_y,
bottom - text->first_y, y_offset,

View File

@ -1,3 +1,8 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* XWorkArea.h:
* XWorkArea.C: use workHeight(), remove enter/leaveView
2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* XWorkArea.h:

View File

@ -391,7 +391,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
!area->work_area->form->visible)
return 1;
lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl;
area->createPixmap(area->workWidth(), area->height());
area->createPixmap(area->workWidth(), area->workHeight());
area->workAreaExpose();
break;
case FL_PUSH:
@ -552,11 +552,9 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
break;
case FL_ENTER:
lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl;
area->workAreaEnter();
break;
case FL_LEAVE:
lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl;
area->workAreaLeave();
break;
case FL_DBLCLICK:
if (!ev) break;

View File

@ -40,12 +40,11 @@ public:
///
int workWidth() const { return work_area->w; }
///
int workHeight() const { return work_area->h; }
///
unsigned int width() const { return work_area->w + scrollbar->w; }
//unsigned int width() const { return backgroundbox->w + 15; }
///
unsigned int height() const { return work_area->h; }
//unsigned int height() const { return backgroundbox->h; }
///
int xpos() const { return work_area->x; }
//int xpos() const { return backgroundbox->x; }
///
@ -120,10 +119,6 @@ public:
///
boost::signal0<void> workAreaUnfocus;
///
boost::signal0<void> workAreaEnter;
///
boost::signal0<void> workAreaLeave;
///
boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
///
boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;