// -*- C++ -*-
-/* This file is part of
-* ======================================================
-*
-* LyX, The Document Processor
-*
-* Copyright (C) 1995 Matthias Ettrich
-* Copyright (C) 1995-1998 The LyX Team.
-*
-*======================================================*/
+/**
+ * \file BufferView.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Lars Gullik Bjønnes
+*/
-#ifndef _BUFFER_VIEW_H
-#define _BUFFER_VIEW_H
+#ifndef BUFFER_VIEW_H
+#define BUFFER_VIEW_H
#ifdef __GNUG__
#pragma interface
#endif
-#include FORMS_H_LOCATION
+#include "LString.h"
+#include "undo.h"
+
+#include "insets/inset.h"
+
+#include <boost/utility.hpp>
class LyXView;
+class LyXText;
+class TeXErrors;
class Buffer;
class LyXScreen;
-class BackStack;
-class Inset;
+class Language;
+class Painter;
+class UpdatableInset;
+class WordLangTuple;
///
-class BufferView {
+class BufferView : boost::noncopyable {
public:
///
- BufferView(LyXView *owner, int ,int ,int, int);
- ///
- ~BufferView();
+ enum UpdateCodes {
+ ///
+ UPDATE = 0,
+ ///
+ SELECT = 1,
+ ///
+ FITCUR = 2,
+ ///
+ CHANGE = 4
+ };
+
+ ///
+ BufferView(LyXView * owner, int , int , int, int);
///
- Buffer *currentBuffer() { return _buffer; }
+ ~BufferView();
///
- FL_OBJECT *getWorkArea() { return work_area; }
+ Buffer * buffer() const;
///
- void setBuffer(Buffer *b);
+ Painter & painter() const;
///
- void resize();
+ LyXScreen & screen() const;
+ ///
+ void buffer(Buffer * b);
///
- void redraw();
+ void resize();
+ /**
+ * Repaint the pixmap. Used for when we don't want
+ * to go through the full update() logic, just a simple
+ * repaint of the whole screen.
+ */
+ void repaint();
///
- void fitCursor();
+ bool fitCursor();
///
void update();
+ //
+ void update(LyXText *, UpdateCodes uc);
///
void updateScrollbar();
///
void redoCurrentBuffer();
///
- int resizeCurrentBuffer();
+ bool available() const;
///
- void gotoError();
+ LyXView * owner() const;
///
- void cursorPrevious();
+ void beforeChange(LyXText *);
///
- void cursorNext();
- ///
- bool available() const;
+ void savePosition(unsigned int i);
///
- LyXView *getOwner() { return _owner; }
- ///
- LyXScreen *getScreen()
- {
- fl_set_timer(timer_cursor, 0.4);
- return screen;
- }
- ///
- void savePosition();
- ///
- void restorePosition();
-private:
- /// Update pixmap of screen
- void updateScreen();
+ void restorePosition(unsigned int i);
///
- int workAreaExpose();
+ bool isSavedPosition(unsigned int i);
+ /** This holds the mapping between buffer paragraphs and screen rows.
+ This should be private...but not yet. (Lgb)
+ */
+ LyXText * text;
///
- void create_view(int, int, int, int);
+ LyXText * getLyXText() const;
///
- Inset * checkInsetHit(int &x, int &y);
- ///
- int ScrollUp(long time);
+ LyXText * getParentText(Inset * inset) const;
///
- int ScrollDown(long time);
+ Language const * getParentLanguage(Inset * inset) const;
///
- void ScrollUpOnePage(long /*time*/);
+ int workWidth() const;
///
- void ScrollDownOnePage(long /*time*/);
-
-public:
- /// A callback for the up arrow in the scrollbar.
- static void UpCB(FL_OBJECT *ob, long);
-
- /// A callback for the slider in the scrollbar.
- static void ScrollCB(FL_OBJECT *ob, long);
-
- /// A callback for the down arrow in the scrollbar.
- static void DownCB(FL_OBJECT *ob, long);
-
+ UpdatableInset * theLockingInset() const;
///
- static void CursorToggleCB(FL_OBJECT *ob, long);
- /** Work area free object handler
- */
- static int work_area_handler(FL_OBJECT *, int event,
- FL_Coord, FL_Coord, int key, void *xev);
-private:
+ void theLockingInset(UpdatableInset * inset);
+ ///
+ void updateInset(Inset * inset, bool mark_dirty);
+ ///
+ int slx;
+ ///
+ int sly;
+ ///
+ void insetUnlock();
///
- int WorkAreaMotionNotify(FL_OBJECT *ob,
- Window win,
- int w, int h,
- XEvent *ev, void *d);
+ void replaceWord(string const & replacestring);
///
- int WorkAreaSelectionNotify(FL_OBJECT *, Window win,
- int /*w*/, int /*h*/,
- XEvent *event, void */*d*/);
+ void endOfSpellCheck();
///
- int WorkAreaButtonPress(FL_OBJECT *ob,
- Window win,
- int w, int h,
- XEvent *ev, void *d);
+ void selectLastWord();
+ /// return the next word
+ WordLangTuple const nextWord(float & value);
///
- int WorkAreaButtonRelease(FL_OBJECT *ob,
- Window win,
- int w, int h,
- XEvent *ev, void *d);
+ bool gotoLabel(string const & label);
///
- LyXView *_owner;
+ void pasteEnvironment();
///
- Buffer *_buffer;
+ void copyEnvironment();
///
- LyXScreen *screen;
+ void menuUndo();
///
- long current_scrollbar_value;
+ void menuRedo();
+ /// removes all autodeletable insets
+ bool removeAutoInsets();
///
- int work_area_width;
+ void insertErrors(TeXErrors & terr);
///
- bool lyx_focus;
+ void setCursorFromRow(int row);
+ /** Insert an inset into the buffer.
+ Place it in a layout of lout,
+ if no_table make sure that it doesn't end up in a table.
+ */
+ bool insertInset(Inset * inset, string const & lout = string());
+ /// Inserts a lyx file at cursor position. return #false# if it fails
+ bool insertLyXFile(string const & file);
///
- bool work_area_focus;
+ bool lockInset(UpdatableInset * inset);
///
- FL_OBJECT *work_area;
+ void showLockedInsetCursor(int x, int y, int asc, int desc);
///
- FL_OBJECT *figinset_canvas;
+ void hideLockedInsetCursor();
///
- FL_OBJECT *scrollbar;
+ bool fitLockedInsetCursor(int x, int y, int asc, int desc);
///
- FL_OBJECT *button_down;
+ int unlockInset(UpdatableInset * inset);
///
- FL_OBJECT *button_up;
+ void lockedInsetStoreUndo(Undo::undo_kind kind);
///
- FL_OBJECT *timer_cursor;
- ///
- BackStack *backstack;
+ void showCursor();
///
- int last_click_x, last_click_y;
+ void hideCursor();
+ ///
+ void toggleSelection(bool = true);
+ ///
+ void toggleToggle();
+ ///
+ void center();
+ /// scroll document by the given number of lines of default height
+ void scroll(int lines);
+
+ /// Scroll the view by a number of pixels
+ void scrollDocView(int);
+
+ ///
+ void switchKeyMap();
+
+ ///
+ bool ChangeInsets(Inset::Code code, string const & from,
+ string const & to);
+ ///
+ bool ChangeRefsIfUnique(string const & from, string const & to);
+ ///
+ bool ChangeCitationsIfUnique(string const & from, string const & to);
+ ///
+ string const getClipboard() const;
+ ///
+ void stuffClipboard(string const &) const;
+ ///
+ bool dispatch(FuncRequest const & argument);
+ /// height of a normal line in pixels (zoom factor considered)
+ int defaultHeight() const;
+ ///
+ void haveSelection(bool sel);
+ ///
+ int workHeight() const;
+
+private:
+ ///
+ struct Pimpl;
+ ///
+ friend struct BufferView::Pimpl;
+ ///
+ Pimpl * pimpl_;
};
+
+///
+BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
+ BufferView::UpdateCodes uc2);
+
#endif