-void BufferView::scrollUpOnePage()
-{
- if (buffer_ == 0) return;
- if (!screen) return;
-
- long y = screen->first;
-
- if (!y) return;
-
- Row * row = text->GetRowNearY(y);
-
- y = y - workarea->height() + row->height;
-
- workarea->setScrollbarValue(y);
-
- scrollCB(y);
-}
-
-
-void BufferView::scrollDownOnePage()
-{
- if (buffer_ == 0) return;
- if (!screen) return;
-
- long y = screen->first;
-
- if (y > text->height - workarea->height())
- return;
-
- y += workarea->height();
- text->GetRowNearY(y);
-
- workarea->setScrollbarValue(y);
-
- scrollCB(y);
-}
-
-
-void BufferView::workAreaMotionNotify(int x, int y, unsigned int state)
-{
- if (buffer_ == 0 || !screen) return;
-
- // Check for inset locking
- if (the_locking_inset) {
- LyXCursor cursor = text->cursor;
- the_locking_inset->
- InsetMotionNotify(this,
- x - cursor.x,
- y - cursor.y,
- state);
- return;
- }
-
- // Only use motion with button 1
- if (!state & Button1MotionMask)
- return;
-
- /* The selection possible is needed, that only motion events are
- * used, where the bottom press event was on the drawing area too */
- if (selection_possible) {
- screen->HideCursor();
-
- text->SetCursorFromCoordinates(x, y + screen->first);
-
- if (!text->selection)
- update(-3); // Maybe an empty line was deleted
-
- text->SetSelection();
- screen->ToggleToggle();
- if (screen->FitCursor())
- updateScrollbar();
- screen->ShowCursor();
- }
- return;
-}
-
-
-extern int bibitemMaxWidth(Painter &, LyXFont const &);
-
-
-// Single-click on work area
-void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
-{
- last_click_x = -1;
- last_click_y = -1;
-
- if (buffer_ == 0 || !screen) return;
-
- Inset * inset_hit = checkInsetHit(xpos, ypos, button);
-
- // ok ok, this is a hack.
- if (button == 4 || button == 5) {
- switch (button) {
- case 4:
- scrollUp(100); // This number is only temporary
- break;
- case 5:
- scrollDown(100);
- break;
- }
- }
-
- if (the_locking_inset) {
- // 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 == the_locking_inset) {
- the_locking_inset->
- InsetButtonPress(this,
- xpos, ypos,
- button);
- return;
- } else {
- unlockInset(the_locking_inset);
- }
- }
-
- if (!inset_hit)
- selection_possible = true;
- screen->HideCursor();
-
- // Right button mouse click on a table
- if (button == 3 &&
- (text->cursor.par->table ||
- text->MouseHitInTable(xpos, ypos + screen->first))) {
- // Set the cursor to the press-position
- text->SetCursorFromCoordinates(xpos, ypos + screen->first);
- bool doit = true;
-
- // Only show the table popup if the hit is in
- // the table, too
- if (!text->HitInTable(text->cursor.row, xpos))
- doit = false;
-
- // Hit above or below the table?
- if (doit) {
- if (!text->selection) {
- screen->ToggleSelection();
- text->ClearSelection();
- text->FullRebreak();
- screen->Update();
- updateScrollbar();
- }
- // Popup table popup when on a table.
- // This is obviously temporary, since we
- // should be able to popup various
- // context-sensitive-menus with the
- // the right mouse. So this should be done more
- // general in the future. Matthias.
- selection_possible = false;
- owner_->getLyXFunc()
- ->Dispatch(LFUN_LAYOUT_TABLE,
- "true");
- return;
- }
- }
-
- int screen_first = screen->first;
-
- // Middle button press pastes if we have a selection
- bool paste_internally = false;
- if (button == 2
- && text->selection) {
- owner_->getLyXFunc()->Dispatch(LFUN_COPY);
- paste_internally = true;
- }
-
- // Clear the selection
- screen->ToggleSelection();
- text->ClearSelection();
- text->FullRebreak();
- screen->Update();
- updateScrollbar();
-
- // Single left click in math inset?
- if ((inset_hit != 0) &&
- (inset_hit->Editable()==Inset::HIGHLY_EDITABLE)) {
- // Highly editable inset, like math
- UpdatableInset *inset = (UpdatableInset *)inset_hit;
- selection_possible = false;
- owner_->updateLayoutChoice();
- owner_->getMiniBuffer()->Set(inset->EditMessage());
- inset->InsetButtonPress(this, xpos, ypos, button);
- inset->Edit(this, xpos, ypos, button);
- return;
- }
-
- // Right click on a footnote flag opens float menu
- if (button == 3) {
- selection_possible = false;
- return;
- }
-
- if (!inset_hit) // otherwise it was already set in checkInsetHit(...)
- text->SetCursorFromCoordinates(xpos, ypos + screen_first);
- text->FinishUndo();
- text->sel_cursor = text->cursor;
- text->cursor.x_fix = text->cursor.x;
-
- owner_->updateLayoutChoice();
- if (screen->FitCursor()){
- updateScrollbar();
- selection_possible = false;
- }
-
- // Insert primary selection with middle mouse
- // if there is a local selection in the current buffer,
- // insert this
- if (button == 2) {
- if (paste_internally)
- owner_->getLyXFunc()->Dispatch(LFUN_PASTE);
- else
- owner_->getLyXFunc()->Dispatch(LFUN_PASTESELECTION,
- "paragraph");
- selection_possible = false;
- return;
- }
-}
-
-
-void BufferView::doubleClick(int /*x*/, int /*y*/, unsigned int button)