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
}
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 =
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);
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;
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;
#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);
}
-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)
{
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
{
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();
}
// 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);
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
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()) {
// 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()
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);
}
}
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);
}
///
void selectionLost();
///
- void enterView();
- ///
- void leaveView();
- ///
void cursorToggle();
///
void cursorPrevious(LyXText *);
+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:
+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:
int PainterBase::paperHeight() const
{
- return owner.height();
+ return owner.workHeight();
}
-// -*- 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
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();
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);
}
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,
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
);
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(),
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());
}
}
{
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)
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);
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;
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);
}
}
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:
- 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);
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,
+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:
!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:
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;
///
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; }
///
///
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;