1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-11-04 01:40:20 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-01-24 18:34:46 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-11-04 01:40:20 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef BUFFER_VIEW_H
|
|
|
|
#define BUFFER_VIEW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
1999-11-04 01:40:20 +00:00
|
|
|
#include "BackStack.h"
|
2000-01-08 21:02:58 +00:00
|
|
|
#include "LaTeX.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "undo.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
#define NEW_WA 1
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
class LyXView;
|
|
|
|
class Buffer;
|
|
|
|
class LyXScreen;
|
|
|
|
class Inset;
|
2000-02-04 09:38:32 +00:00
|
|
|
class LyXText;
|
2000-02-10 17:53:36 +00:00
|
|
|
class WorkArea;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
class BufferView {
|
|
|
|
public:
|
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
BufferView(LyXView * owner, int , int , int, int);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
~BufferView();
|
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
Buffer * buffer() const { return buffer_; }
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifdef USE_PAINTER
|
|
|
|
///
|
|
|
|
Painter & painter();
|
|
|
|
#endif
|
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
WorkArea * getWorkArea() { return workarea; }
|
|
|
|
#else
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * getWorkArea() { return work_area; }
|
2000-02-10 17:53:36 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
void buffer(Buffer * b);
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
void resize(int, int, int, int);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void resize();
|
|
|
|
///
|
|
|
|
void redraw();
|
|
|
|
///
|
|
|
|
void fitCursor();
|
|
|
|
///
|
|
|
|
void update();
|
1999-12-10 00:07:59 +00:00
|
|
|
///
|
|
|
|
void update(signed char f);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-01-06 02:44:26 +00:00
|
|
|
void smallUpdate(signed char f);
|
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
void updateScrollbar();
|
|
|
|
///
|
|
|
|
void redoCurrentBuffer();
|
|
|
|
///
|
|
|
|
int resizeCurrentBuffer();
|
|
|
|
///
|
|
|
|
void gotoError();
|
|
|
|
///
|
|
|
|
void cursorPrevious();
|
|
|
|
///
|
|
|
|
void cursorNext();
|
|
|
|
///
|
|
|
|
bool available() const;
|
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
LyXView * owner() const { return owner_; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
LyXScreen * getScreen() {
|
|
|
|
fl_set_timer(timer_cursor, 0.4);
|
|
|
|
return screen;
|
|
|
|
}
|
2000-01-07 03:42:16 +00:00
|
|
|
///
|
|
|
|
void beforeChange();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void savePosition();
|
|
|
|
///
|
|
|
|
void restorePosition();
|
1999-12-10 00:07:59 +00:00
|
|
|
/** This holds the mapping between buffer paragraphs and screen rows.
|
|
|
|
This should be private...but not yet. (Lgb)
|
|
|
|
*/
|
|
|
|
LyXText * text;
|
2000-01-07 03:42:16 +00:00
|
|
|
///
|
|
|
|
UpdatableInset * the_locking_inset;
|
|
|
|
///
|
|
|
|
bool inset_slept;
|
|
|
|
///
|
|
|
|
int slx;
|
|
|
|
///
|
|
|
|
int sly;
|
|
|
|
///
|
|
|
|
void insetUnlock();
|
|
|
|
///
|
|
|
|
void insetSleep();
|
|
|
|
///
|
|
|
|
void insetWakeup();
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
|
|
|
void replaceWord(string const & replacestring);
|
|
|
|
///
|
|
|
|
void endOfSpellCheck();
|
|
|
|
///
|
|
|
|
void selectLastWord();
|
|
|
|
///
|
|
|
|
char * nextWord(float & value);
|
|
|
|
///
|
|
|
|
void insertCorrectQuote();
|
|
|
|
///
|
|
|
|
void gotoNote();
|
|
|
|
///
|
|
|
|
bool gotoLabel(string const & label);
|
|
|
|
///
|
|
|
|
void paste();
|
|
|
|
///
|
|
|
|
void cut();
|
|
|
|
///
|
|
|
|
void copy();
|
|
|
|
///
|
|
|
|
void pasteEnvironment();
|
|
|
|
///
|
|
|
|
void copyEnvironment();
|
|
|
|
///
|
|
|
|
void hfill();
|
|
|
|
///
|
|
|
|
void protectedBlank();
|
|
|
|
///
|
|
|
|
void newline();
|
|
|
|
///
|
|
|
|
void menuSeparator();
|
|
|
|
///
|
|
|
|
void endOfSentenceDot();
|
|
|
|
///
|
|
|
|
void ldots();
|
|
|
|
///
|
|
|
|
void hyphenationPoint();
|
|
|
|
///
|
|
|
|
void menuUndo();
|
|
|
|
///
|
|
|
|
void menuRedo();
|
|
|
|
///
|
|
|
|
void toggleFloat();
|
|
|
|
///
|
|
|
|
void openStuff();
|
|
|
|
///
|
|
|
|
void insertNote();
|
|
|
|
///
|
|
|
|
void allFloats(char flag, char figmar);
|
|
|
|
/// removes all autodeletable insets
|
|
|
|
bool removeAutoInsets();
|
|
|
|
///
|
|
|
|
void insertErrors(TeXErrors & terr);
|
|
|
|
///
|
|
|
|
void setCursorFromRow(int row);
|
|
|
|
/** Insert an inset into the buffer
|
|
|
|
Insert inset into buffer, placing it in a layout of lout,
|
|
|
|
if no_table make sure that it doesn't end up in a table. */
|
|
|
|
void insertInset(Inset * inset, string const & lout = string(),
|
|
|
|
bool no_table = false);
|
|
|
|
/// open and lock an updatable inset
|
|
|
|
void open_new_inset(UpdatableInset * new_inset);
|
|
|
|
/// Inserts a lyx file at cursor position. Returns false if it fails.
|
|
|
|
bool insertLyXFile(string const & file);
|
|
|
|
///
|
|
|
|
int lockInset(UpdatableInset * inset);
|
|
|
|
///
|
|
|
|
void showLockedInsetCursor(long x, long y, int asc, int desc);
|
|
|
|
///
|
|
|
|
void hideLockedInsetCursor(long x, long y, int asc, int desc);
|
|
|
|
///
|
|
|
|
void fitLockedInsetCursor(long x, long y, int asc, int desc);
|
|
|
|
///
|
|
|
|
int unlockInset(UpdatableInset * inset);
|
|
|
|
///
|
|
|
|
void lockedInsetStoreUndo(Undo::undo_kind kind);
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2000-02-10 17:53:36 +00:00
|
|
|
friend class WorkArea;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Update pixmap of screen
|
|
|
|
void updateScreen();
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
void workAreaExpose();
|
|
|
|
///
|
|
|
|
void ScrollUpOnePage();
|
|
|
|
///
|
|
|
|
void ScrollDownOnePage();
|
|
|
|
#else
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
int workAreaExpose();
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
void ScrollUpOnePage(long /*time*/);
|
|
|
|
///
|
|
|
|
void ScrollDownOnePage(long /*time*/);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void create_view(int, int, int, int);
|
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
Inset * checkInsetHit(int & x, int & y);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
int ScrollUp(long time);
|
|
|
|
///
|
|
|
|
int ScrollDown(long time);
|
|
|
|
|
1999-10-25 14:18:30 +00:00
|
|
|
public:
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
bool focus() const;
|
|
|
|
///
|
|
|
|
void focus(bool);
|
|
|
|
///
|
|
|
|
bool active() const;
|
|
|
|
/// A callback for the up arrow in the scrollbar.
|
|
|
|
void UpCB(long time, int button);
|
|
|
|
/// A callback for the slider in the scrollbar.
|
|
|
|
void ScrollCB(double);
|
|
|
|
/// A callback for the down arrow in the scrollbar.
|
|
|
|
void DownCB(long time, int button);
|
|
|
|
#else
|
1999-09-27 18:44:28 +00:00
|
|
|
/// A callback for the up arrow in the scrollbar.
|
1999-11-09 23:52:04 +00:00
|
|
|
static void UpCB(FL_OBJECT * ob, long);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// A callback for the slider in the scrollbar.
|
1999-11-09 23:52:04 +00:00
|
|
|
static void ScrollCB(FL_OBJECT * ob, long);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// A callback for the down arrow in the scrollbar.
|
1999-11-09 23:52:04 +00:00
|
|
|
static void DownCB(FL_OBJECT * ob, long);
|
2000-02-10 17:53:36 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-25 14:18:30 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
static void CursorToggleCB(FL_OBJECT * ob, long);
|
1999-09-27 18:44:28 +00:00
|
|
|
/** Work area free object handler
|
|
|
|
*/
|
|
|
|
static int work_area_handler(FL_OBJECT *, int event,
|
|
|
|
FL_Coord, FL_Coord, int key, void *xev);
|
2000-02-03 19:51:27 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void SetState();
|
|
|
|
|
1999-10-25 14:18:30 +00:00
|
|
|
private:
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
void WorkAreaMotionNotify(int x, int y, unsigned int state);
|
|
|
|
///
|
|
|
|
void WorkAreaButtonPress(int x, int y, unsigned int button);
|
|
|
|
///
|
|
|
|
void WorkAreaButtonRelease(int x, int y, unsigned int button);
|
|
|
|
///
|
|
|
|
void WorkAreaSelectionNotify(Window win, XEvent * event);
|
|
|
|
#else
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
int WorkAreaMotionNotify(FL_OBJECT * ob,
|
1999-09-27 18:44:28 +00:00
|
|
|
Window win,
|
|
|
|
int w, int h,
|
1999-11-09 23:52:04 +00:00
|
|
|
XEvent * ev, void * d);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
int WorkAreaButtonPress(FL_OBJECT * ob,
|
1999-09-27 18:44:28 +00:00
|
|
|
Window win,
|
|
|
|
int w, int h,
|
1999-11-09 23:52:04 +00:00
|
|
|
XEvent * ev, void * d);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
int WorkAreaButtonRelease(FL_OBJECT * ob,
|
1999-09-27 18:44:28 +00:00
|
|
|
Window win,
|
|
|
|
int w, int h,
|
1999-11-09 23:52:04 +00:00
|
|
|
XEvent * ev, void * d);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-10 17:53:36 +00:00
|
|
|
int WorkAreaSelectionNotify(FL_OBJECT *, Window win,
|
|
|
|
int /*w*/, int /*h*/,
|
|
|
|
XEvent * event, void * /*d*/);
|
|
|
|
#endif
|
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
LyXView * owner_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
Buffer * buffer_;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
LyXScreen * screen;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
long current_scrollbar_value;
|
|
|
|
///
|
|
|
|
bool lyx_focus;
|
|
|
|
///
|
|
|
|
bool work_area_focus;
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifndef NEW_WA
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * work_area;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * scrollbar;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * button_down;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * button_up;
|
2000-02-10 17:53:36 +00:00
|
|
|
#endif
|
|
|
|
///
|
|
|
|
FL_OBJECT * figinset_canvas;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
FL_OBJECT * timer_cursor;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
BackStack backstack;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
int last_click_x, last_click_y;
|
2000-02-10 17:53:36 +00:00
|
|
|
#ifdef NEW_WA
|
|
|
|
///
|
|
|
|
WorkArea * workarea;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|