+2000-02-18 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * WorkArea, Painter, LyXScreen: Fixed the crash that occured on
+ resize due to wrong pixmap beeing used. Also took the opurtunity
+ to make the LyXScreen stateless on regard to WorkArea and some
+ general cleanup in the same files.
+
2000-02-17 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/Makefile.am: add missing direction.h
case $gxx_version in
2.7*) CXXFLAGS="$lyx_opt";;
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
- 2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+ 2.95.*) CXXFLAGS="-g $lyx_opt -Woverloaded-virtual -fno-rtti -fno-exceptions";;
*2.91.*) CXXFLAGS="-g $lyx_opt -Wno-return-type -fno-exceptions -fno-rtti";;
*) CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";;
esac
case $gxx_version in
2.7*) CXXFLAGS="$lyx_opt";;
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
- 2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+ 2.95.*) CXXFLAGS="-g $lyx_opt -Woverloaded-virtual -fno-rtti -fno-exceptions";;
*2.91.*) CXXFLAGS="-g $lyx_opt -Wno-return-type -fno-exceptions -fno-rtti";;
*) CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";;
esac
#include "LyXView.h"
#include "lyxfunc.h"
#include "insets/lyxinset.h"
+#include "insets/insetbib.h"
#include "minibuffer.h"
#include "lyxscreen.h"
{
buffer_ = 0;
text = 0;
- screen = 0;
workarea = new WorkArea(this, xpos, ypos, width, height);
+ screen = 0;
timer_cursor = 0;
create_view();
current_scrollbar_value = 0;
{
// Regenerate the screen.
delete screen;
- screen = new LyXScreen(this,
- workarea->getWin(),
- workarea->getPixmap(),
- workarea->workWidth(),
- workarea->height(),
- workarea->xpos(),
- workarea->ypos(),
- text);
+ screen = new LyXScreen(*workarea, text);
}
void BufferView::hideLockedInsetCursor()
{
if (the_locking_inset && available()) {
- screen->HideManualCursor();
+ screen->HideCursor();
}
}
#include "lyxfont.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
+#include "WorkArea.h"
Painter::Painter(WorkArea & wa)
: PainterBase(wa)
}
+Drawable Painter::drawable() const
+{
+ return owner.getPixmap();
+}
+
+
/* Basic drawing routines */
extern bool Lgb_bug_find_hack;
if (!Lgb_bug_find_hack)
lyxerr << "point not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable << endl;
+ lyxerr.debug() << "Painter drawable: " << drawable() << endl;
}
- XDrawPoint(display, drawable, getGCForeground(c), x, y);
+ XDrawPoint(display, drawable(), getGCForeground(c), x, y);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "line not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable << endl;
+ lyxerr.debug() << "Painter drawable: " << drawable() << endl;
}
- XDrawLine(display, drawable,
+ XDrawLine(display, drawable(),
getGCLinepars(ls, lw, col), x1, y1, x2, y2);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "lines not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable << endl;
+ lyxerr.debug() << "Painter drawable: " << drawable() << endl;
}
#ifndef HAVE_AUTO_PTR
points[i].y = yp[i];
}
- XDrawLines(display, drawable, getGCLinepars(ls, lw, col),
+ XDrawLines(display, drawable(), getGCLinepars(ls, lw, col),
points, np, CoordModeOrigin);
#ifndef HAVE_AUTO_PTR
if (!Lgb_bug_find_hack)
lyxerr << "rectangle not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
- XDrawRectangle(display, drawable, getGCLinepars(ls, lw, col),
+ XDrawRectangle(display, drawable(), getGCLinepars(ls, lw, col),
x, y, w, h);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "fillrectangle not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
- XFillRectangle(display, drawable, getGCForeground(col), x, y, w, h);
+ XFillRectangle(display, drawable(), getGCForeground(col), x, y, w, h);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr <<"fillpolygon not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
#ifndef HAVE_AUTO_PTR
points[i].y = yp[i];
}
- XFillPolygon(display, drawable, getGCForeground(col), points, np,
+ XFillPolygon(display, drawable(), getGCForeground(col), points, np,
Nonconvex, CoordModeOrigin);
#ifndef HAVE_AUTO_PTR
delete[] points;
if (!Lgb_bug_find_hack)
lyxerr << "arc not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
- XDrawArc(display, drawable, getGCForeground(col),
+ XDrawArc(display, drawable(), getGCForeground(col),
x, y, w, h, a1, a2);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "segments not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
#ifndef HAVE_AUTO_PTR
s[i].x2 = x2[i];
s[i].y2 = y2[i];
}
- XDrawSegments(display, drawable, getGCLinepars(ls, lw, col), s, ns);
+ XDrawSegments(display, drawable(), getGCLinepars(ls, lw, col), s, ns);
#ifndef HAVE_AUTO_PTR
delete [] s;
if (!Lgb_bug_find_hack)
lyxerr << "workAreaExpose not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
XGCValues val;
val.function = GXcopy;
- GC gc = XCreateGC(display, drawable,
+ GC gc = XCreateGC(display, drawable(),
GCFunction, &val);
- XCopyArea(display, bitmap, drawable, gc,
+ XCopyArea(display, bitmap, drawable(), gc,
0, 0, w, h, x, y);
XFreeGC(display, gc);
return *this;
if (!Lgb_bug_find_hack)
lyxerr << "text not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
GC gc = getGCForeground(f.realColor());
XSetFont(display, gc, f.getFontID());
- XDrawString(display, drawable, gc, x, y, s, ls);
+ XDrawString(display, drawable(), gc, x, y, s, ls);
underline(f, x, y, this->width(s, ls, f));
return *this;
}
GC Painter::getGCForeground(LColor::color c)
{
if (lyxerr.debugging()) {
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
if (colorGCcache[c] != 0) return colorGCcache[c];
}
val.function = GXcopy;
- return colorGCcache[c] = XCreateGC(display, drawable,
+ return colorGCcache[c] = XCreateGC(display, drawable(),
GCForeground | GCFunction, &val);
}
enum line_width lw, LColor::color c)
{
if (lyxerr.debugging()) {
- lyxerr << "Painter drawable: " << drawable << endl;
+ lyxerr << "Painter drawable: " << drawable() << endl;
}
int index = lw + (ls << 1) + (c << 3);
val.function = GXcopy;
return lineGCcache[index] =
- XCreateGC(display, drawable,
+ XCreateGC(display, drawable(),
GCForeground | GCLineStyle | GCLineWidth |
GCCapStyle | GCJoinStyle | GCFunction, &val);
}
///
PainterBase & setDisplay(Display * d) { display = d; return *this; }
- ///
- PainterBase & setDrawable(Drawable d) { drawable = d; return *this; }
-
/// Get foreground color in ordinary GC
GC getGCForeground(LColor::color c);
/**@Low level X parameters */
///
Display * display;
+
///
- Drawable drawable;
+ Drawable drawable() const;
+
///
Colormap colormap;
int & width = PainterBase::dummy1,
int & ascent = PainterBase::dummy2,
int & descent = PainterBase::dummy3);
-private:
+protected:
WorkArea & owner;
};
// setup the painter
painter_.setDisplay(fl_display);
- painter_.setDrawable(workareapixmap);
// We add this object as late as possible to avoit problems
// with drawing.
// Create the workarea pixmap
createPixmap(width - 15 - 2 * bw, height - 2 * bw);
- // reset the painter
- painter_.setDrawable(workareapixmap);
-
// the free object
fl_set_object_geometry(work_area, xpos + bw, ypos + bw,
width - 15 - 2 * bw,
}
-void InsetFig::Write(ostream & os)
+void InsetFig::Write(ostream & os) const
{
Regenerate();
os << "Figure size " << wid << " " << hgh << "\n";
}
-int InsetFig::Latex(ostream & os, signed char /* fragile*/ )
+int InsetFig::Latex(ostream & os, signed char /* fragile*/ ) const
{
Regenerate();
if (!cmd.empty()) os << cmd << " ";
}
-int InsetFig::Latex(string & file, signed char /* fragile*/ )
+int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
{
Regenerate();
file += cmd + ' ';
}
-int InsetFig::Linuxdoc(string &/*file*/)
+int InsetFig::Linuxdoc(string &/*file*/) const
{
return 0;
}
-int InsetFig::DocBook(string & file)
+int InsetFig::DocBook(string & file) const
{
string figurename = fname;
}
-void InsetFig::Regenerate()
+void InsetFig::Regenerate() const
{
string cmdbuf;
string resizeW, resizeH;
void draw(Painter &, LyXFont const & font,
int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
/// Updates needed features for this inset.
void Validate(LaTeXFeatures & features) const;
float angle;
/// graphics command, latex version
- string cmd;
+ mutable string cmd;
/// Caption for subfigure package
string subcaption;
/// recompute screen params
void Recompute();
/// regenerate \includegraphics{} command
- void Regenerate();
+ void Regenerate() const;
/// regenerate \inlcudegraphics{} command in temporary buffer
void TempRegenerate();
/// get sizes from .eps file
// as a LyX 2.x command, and lyxlex is not enough smart to understand
// real LaTeX commands. Yes, that could be fixed, but would be a waste
// of time cause LyX3 won't use lyxlex anyway. (ale)
-void InsetBibKey::Write(ostream & os)
+void InsetBibKey::Write(ostream & os) const
{
string s;
if (!options.empty()) {
}
-int InsetBibtex::Latex(ostream & os, signed char /*fragile*/)
+int InsetBibtex::Latex(ostream & os, signed char /*fragile*/) const
{
string bib;
signed char dummy = 0;
}
-int InsetBibtex::Latex(string & file, signed char /*fragile*/)
+int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
{
// this looks like an horrible hack and it is :) The problem
// is that owner is not initialized correctly when the bib
///
Inset * Clone() const { return new InsetBibKey(this); }
/// Currently \bibitem is used as a LyX2.x command, so we need this method.
- void Write(ostream &);
+ void Write(ostream &) const;
///
virtual string getScreenLabel() const;
///
///
void Edit(int, int);
///
- int Latex(ostream &, signed char);
+ int Latex(ostream &, signed char) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
string getKeys(char delim);
///
bool display() const { return true; }
private:
///
- Buffer * owner;
+ mutable Buffer * owner;
};
#endif
// In lyxf3 this will be just LaTeX
-void InsetCommand::Write(ostream & os)
+void InsetCommand::Write(ostream & os) const
{
os << "LatexCommand " << getCommand() << "\n";
}
}
-int InsetCommand::Latex(ostream & os, signed char /*fragile*/)
+int InsetCommand::Latex(ostream & os, signed char /*fragile*/) const
{
os << getCommand();
return 0;
}
-int InsetCommand::Latex(string & file, signed char /*fragile*/)
+int InsetCommand::Latex(string & file, signed char /*fragile*/) const
{
file += getCommand();
return 0;
}
-int InsetCommand::Linuxdoc(string &/*file*/)
+int InsetCommand::Linuxdoc(string &/*file*/) const
{
return 0;
}
-int InsetCommand::DocBook(string &/*file*/)
+int InsetCommand::DocBook(string &/*file*/) const
{
return 0;
}
///
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
/// Parse the command.
void scanCommand(string const & cmd);
/// Will not be used when lyxf3
void Read(LyXLex & lex);
///
- virtual int Latex(ostream &, signed char fragile);
+ virtual int Latex(ostream &, signed char fragile) const;
///
- virtual int Latex(string & file, signed char fragile);
+ virtual int Latex(string & file, signed char fragile) const;
///
- virtual int Linuxdoc(string & file);
+ virtual int Linuxdoc(string & file) const;
///
- virtual int DocBook(string & file);
+ virtual int DocBook(string & file) const;
///
Inset * Clone() const;
///
}
-void InsetError::Write(ostream &)
+void InsetError::Write(ostream &) const
{
}
}
-int InsetError::Latex(ostream &, signed char /*fragile*/)
+int InsetError::Latex(ostream &, signed char /*fragile*/) const
{
return 0;
}
-int InsetError::Latex(string &, signed char /*fragile*/)
+int InsetError::Latex(string &, signed char /*fragile*/) const
{
return 0;
}
-int InsetError::Linuxdoc(string &)
+int InsetError::Linuxdoc(string &) const
{
return 0;
}
-int InsetError::DocBook(string &)
+int InsetError::DocBook(string &) const
{
return 0;
}
void draw(Painter &, LyXFont const & font,
int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
bool AutoDelete() const;
/// what appears in the minibuffer when opening
}
-void InsetInclude::Write(ostream & os)
+void InsetInclude::Write(ostream & os) const
{
os << "Include " << getCommand() << "\n";
}
}
-int InsetInclude::Latex(ostream & os, signed char /*fragile*/)
+int InsetInclude::Latex(ostream & os, signed char /*fragile*/) const
{
string include_file;
signed char dummy = 0;
}
-int InsetInclude::Latex(string & file, signed char /*fragile*/)
+int InsetInclude::Latex(string & file, signed char /*fragile*/) const
{
string writefile, incfile;
return 1;
}
/// With lyx3 we won't overload these 3 methods
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex &);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
void Validate(LaTeXFeatures &) const;
}
-void InsetInfo::Write(ostream & os)
+void InsetInfo::Write(ostream & os) const
{
os << "Info " << contents;
}
}
-int InsetInfo::Latex(ostream &, signed char /*fragile*/)
+int InsetInfo::Latex(ostream &, signed char /*fragile*/) const
{
return 0;
}
-int InsetInfo::Latex(string &, signed char /*fragile*/)
+int InsetInfo::Latex(string &, signed char /*fragile*/) const
{
return 0;
}
-int InsetInfo::Linuxdoc(string &)
+int InsetInfo::Linuxdoc(string &) const
{
return 0;
}
-int InsetInfo::DocBook(string &)
+int InsetInfo::DocBook(string &) const
{
return 0;
}
///
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
/// what appears in the minibuffer when opening
char const * EditMessage() const {return _("Opened note");}
///
}
-int InsetLabel::Latex(ostream & os, signed char /*fragile*/)
+int InsetLabel::Latex(ostream & os, signed char /*fragile*/) const
{
os << escape(getCommand());
return 0;
}
-int InsetLabel::Latex(string & file, signed char /*fragile*/)
+int InsetLabel::Latex(string & file, signed char /*fragile*/) const
{
file += escape(getCommand());
return 0;
}
-int InsetLabel::Linuxdoc(string & file)
+int InsetLabel::Linuxdoc(string & file) const
{
file += "<label id=\"" + getContents() +"\" >";
return 0;
}
-int InsetLabel::DocBook(string & file)
+int InsetLabel::DocBook(string & file) const
{
file += "<anchor id=\"" + getContents() +"\" >";
return 0;
///
unsigned char Editable() const { return 0; }
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
private:
/// This function escapes 8-bit characters
string escape(string const &) const;
}
-void InsetLatexAccent::Write(ostream & os)
+void InsetLatexAccent::Write(ostream & os) const
{
os << "\\i " << contents << "\n";
}
}
-int InsetLatexAccent::Latex(ostream & os, signed char /*fragile*/)
+int InsetLatexAccent::Latex(ostream & os, signed char /*fragile*/) const
{
os << contents;
return 0;
}
-int InsetLatexAccent::Latex(string & file, signed char /*fragile*/)
+int InsetLatexAccent::Latex(string & file, signed char /*fragile*/) const
{
file += contents;
return 0;
}
-int InsetLatexAccent::Linuxdoc(string & file)
+int InsetLatexAccent::Linuxdoc(string & file) const
{
file += contents;
return 0;
}
-int InsetLatexAccent::DocBook(string & file)
+int InsetLatexAccent::DocBook(string & file) const
{
file += contents;
return 0;
bool DisplayISO8859_9(Painter &, LyXFont const & font,
int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
bool Deletable() const;
///
// LaTeX must just ignore this command
-int InsetParent::Latex(ostream & os, signed char fragile)
+int InsetParent::Latex(ostream & os, signed char fragile) const
{
os << "%%#{lyx}";
InsetCommand::Latex(os, fragile);
// LaTeX must just ignore this command
-int InsetParent::Latex(string & file, signed char fragile)
+int InsetParent::Latex(string & file, signed char fragile) const
{
file += "%%#{lyx}";
InsetCommand::Latex(file, fragile);
///
InsetParent(string const & fn, Buffer * owner = 0);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
Inset * Clone() const { return new InsetParent(getContents()); }
///
}
-void InsetQuotes::Write(ostream & os)
+void InsetQuotes::Write(ostream & os) const
{
string text;
text += language_char[language];
}
-int InsetQuotes::Latex(ostream & os, signed char /*fragile*/)
+int InsetQuotes::Latex(ostream & os, signed char /*fragile*/) const
{
string quote;
int res = Latex(quote, 0);
}
-int InsetQuotes::Latex(string & file, signed char /*fragile*/)
+int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
{
string doclang =
current_view->buffer()->GetLanguage();
}
-int InsetQuotes::Linuxdoc(string & file)
+int InsetQuotes::Linuxdoc(string & file) const
{
file += "\"";
}
-int InsetQuotes::DocBook(string & file)
+int InsetQuotes::DocBook(string & file) const
{
if(times == InsetQuotes::DoubleQ) {
if (side == InsetQuotes::LeftQ)
///
LyXFont ConvertFont(LyXFont font);
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
void Validate(LaTeXFeatures &) const;
///
}
-int InsetRef::Latex(ostream & os, signed char /*fragile*/)
+int InsetRef::Latex(ostream & os, signed char /*fragile*/) const
{
if(getOptions().empty())
os << escape(getCommand());
}
-int InsetRef::Latex(string & file, signed char /*fragile*/)
+int InsetRef::Latex(string & file, signed char /*fragile*/) const
{
if(getOptions().empty())
file += escape(getCommand());
}
-int InsetRef::Linuxdoc(string & file)
+int InsetRef::Linuxdoc(string & file) const
{
file += "<ref id=\"" + getContents()
+ "\" name=\""+ getOptions() +"\" >" ;
}
-int InsetRef::DocBook(string & file)
+int InsetRef::DocBook(string & file) const
{
file += "<link linkend=\"" + getContents()
+ "\">"+ getOptions() +"</link>" ;
///
void gotoLabel();
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
private:
/// This function escapes 8-bit characters
string escape(string const &) const;
// In lyxf3 this will be just LaTeX
-void InsetSpecialChar::Write(ostream & os)
+void InsetSpecialChar::Write(ostream & os) const
{
string command;
switch (kind) {
}
-int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/)
+int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/) const
{
string command;
signed char dummy = 0;
}
-int InsetSpecialChar::Latex(string & file, signed char /*fragile*/)
+int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
{
switch (kind) {
case HYPHENATION: file += "\\-"; break;
}
-int InsetSpecialChar::Linuxdoc(string & file)
+int InsetSpecialChar::Linuxdoc(string & file) const
{
switch (kind) {
case HYPHENATION: file += ""; break;
}
-int InsetSpecialChar::DocBook(string & file)
+int InsetSpecialChar::DocBook(string & file) const
{
switch (kind) {
case HYPHENATION: file += ""; break;
///
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
/// Will not be used when lyxf3
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
Inset * Clone() const;
///
}
-int InsetUrl::Latex(ostream & os, signed char fragile)
+int InsetUrl::Latex(ostream & os, signed char fragile) const
{
string latex_output;
int res = Latex(latex_output, fragile);
}
-int InsetUrl::Latex(string & file, signed char fragile)
+int InsetUrl::Latex(string & file, signed char fragile) const
{
if (!getOptions().empty())
file += getOptions() + ' ';
}
-int InsetUrl::Linuxdoc(string & file)
+int InsetUrl::Linuxdoc(string & file) const
{
file += "<"+ getCmdName() +
" url=\"" + getContents()+"\"" +
}
-int InsetUrl::DocBook(string & file)
+int InsetUrl::DocBook(string & file) const
{
file += "<ulink url=\"" + getContents() + "\">" +
getOptions() +"</ulink>";
///
void gotoLabel();
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
static void CloseUrlCB(FL_OBJECT *, long data);
private:
///
virtual bool AutoDelete() const;
///
- virtual void Write(ostream &) = 0;
+ virtual void Write(ostream &) const = 0;
///
virtual void Read(LyXLex & lex) = 0;
/** returns the number of rows (\n's) of generated tex code.
fragile != 0 means, that the inset should take care about
fragile commands by adding a \protect before.
*/
- virtual int Latex(ostream &, signed char fragile) = 0;
+ virtual int Latex(ostream &, signed char fragile) const = 0;
///
- virtual int Latex(string & file, signed char fragile) = 0;
+ virtual int Latex(string & file, signed char fragile) const = 0;
///
- virtual int Linuxdoc(string & /*file*/) = 0;
+ virtual int Linuxdoc(string & /*file*/) const = 0;
///
- virtual int DocBook(string & /*file*/) = 0;
+ virtual int DocBook(string & /*file*/) const = 0;
/// Updates needed features for this inset.
virtual void Validate(LaTeXFeatures & features) const;
///
LyXFont(LyXFont::FONT_INIT3);
/// LyXFont x, y; x = y;
- LyXFont& operator=(LyXFont const & x);
+ LyXFont & operator=(LyXFont const & x);
/// Decreases font size by one
LyXFont & decSize();
#include <list>
#include "insets/lyxinset.h"
-#include "insets/insetbib.h"
#include "table.h"
#include "vspace.h"
#include "layout.h"
class LyXBuffer;
class TexRow;
struct LaTeXFeatures;
+class InsetBibKey;
using std::list;
struct Row;
typedef unsigned short Dimension;
-class BufferView;
+class WorkArea;
/** The class LyXScreen is used for the main Textbody.
Concretely, the screen is held in a pixmap. This pixmap is kept up to
class LyXScreen {
public:
///
- LyXScreen(BufferView *, Window window,
- Pixmap p,
- Dimension width,
- Dimension height,
- Dimension offset_x,
- Dimension offset_y,
- LyXText * text_ptr);
- ///
- ~LyXScreen();
+ LyXScreen(WorkArea &, LyXText * text_ptr);
/** Draws the screen form textposition y. Uses as much of
the already printed pixmap as possible */
void CursorToggle();
///
void ShowManualCursor(long x, long y, int asc, int desc);
- ///
- void HideManualCursor();
/// returns 1 if first has changed, otherwise 0
int FitManualCursor(long, long, int, int);
///
void DrawOneRow(Row * row, long & y_text);
///
- BufferView * owner;
+ WorkArea & owner;
///
LyXText * text;
- ///
- Pixmap foreground;
///
Pixmap cursor_pixmap;
///
///
int cursor_pixmap_h;
///
- Window _window;
- ///
- Dimension _width;
- ///
- Dimension _height;
- ///
- Dimension _offset_x;
- ///
- Dimension _offset_y;
- ///
long screen_refresh_y;
///
Row * screen_refresh_row;
}
-void InsetFormula::Write(ostream & os)
+void InsetFormula::Write(ostream & os) const
{
os << "Formula ";
Latex(os, 0);
}
-int InsetFormula::Latex(ostream & os, signed char fragile)
+int InsetFormula::Latex(ostream & os, signed char fragile) const
{
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
}
-int InsetFormula::Latex(string & file, signed char fragile)
+int InsetFormula::Latex(string & file, signed char fragile) const
{
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
}
-int InsetFormula::Linuxdoc(string &/*file*/)
+int InsetFormula::Linuxdoc(string &/*file*/) const
{
return 0;
}
-int InsetFormula::DocBook(string &/*file*/)
+int InsetFormula::DocBook(string &/*file*/) const
{
return 0;
}
///
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
///
- void Write(ostream &);
+ void Write(ostream &) const;
///
void Read(LyXLex & lex);
///
- int Latex(ostream &, signed char fragile);
+ int Latex(ostream &, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
void Validate(LaTeXFeatures &) const;
///
}
-void InsetFormulaMacro::Write(ostream & os)
+void InsetFormulaMacro::Write(ostream & os) const
{
os << "FormulaMacro ";
Latex(os, 0);
}
-int InsetFormulaMacro::Latex(ostream & os, signed char /*fragile*/)
+int InsetFormulaMacro::Latex(ostream & os, signed char /*fragile*/) const
{
int ret = 1;
tmacro->WriteDef(os);
}
-int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/)
+int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/) const
{
int ret = 1;
tmacro->WriteDef(file);
}
-int InsetFormulaMacro::Linuxdoc(string &/*file*/)
+int InsetFormulaMacro::Linuxdoc(string &/*file*/) const
{
return 0;
}
-int InsetFormulaMacro::DocBook(string &/*file*/)
+int InsetFormulaMacro::DocBook(string &/*file*/) const
{
return 0;
}
///
void Read(LyXLex & lex);
///
- void Write(ostream & os);
+ void Write(ostream & os) const;
///
- int Latex(ostream & os, signed char fragile);
+ int Latex(ostream & os, signed char fragile) const;
///
- int Latex(string & file, signed char fragile);
+ int Latex(string & file, signed char fragile) const;
///
- int Linuxdoc(string & file);
+ int Linuxdoc(string & file) const;
///
- int DocBook(string & file);
+ int DocBook(string & file) const;
///
Inset * Clone() const;
#include "debug.h"
#include "LaTeXFeatures.h"
#include "insets/insetinclude.h"
+#include "insets/insetbib.h"
#include "support/filetools.h"
#include "lyx_gui_misc.h"
#include "texrow.h"
#pragma implementation "lyxscreen.h"
#endif
+#include <algorithm>
+
#include "lyxscreen.h"
#include "lyxtext.h"
#include "lyxrow.h"
-#include "BufferView.h"
#include "Painter.h"
+#include "WorkArea.h"
+using std::max;
+using std::min;
static
GC createGC()
// Constructor
-LyXScreen::LyXScreen(BufferView * o, Window window,
- Pixmap p,
- Dimension width,
- Dimension height,
- Dimension offset_x,
- Dimension offset_y,
- LyXText *text_ptr)
- : owner(o), text(text_ptr), _window(window),
- _width(width), _height(height),
- _offset_x(offset_x), _offset_y(offset_y)
+LyXScreen::LyXScreen(WorkArea & o, LyXText * text_ptr)
+ : owner(o), text(text_ptr)
{
first = 0;
cursor_visible = false;
screen_refresh_y = -1;
- /* create the foreground pixmap */
- foreground = p;
-
cursor_pixmap = 0;
cursor_pixmap_x = 0;
cursor_pixmap_y = 0;
}
-// Destructor
-LyXScreen::~LyXScreen() {}
-
-
void LyXScreen::Redraw()
{
- DrawFromTo(0, _height);
+ DrawFromTo(0, owner.height());
screen_refresh_y = -1;
- expose(0, 0, _width, _height);
+ expose(0, 0, owner.workWidth(), owner.height());
if (cursor_visible) {
cursor_visible = false;
ShowCursor();
void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
{
XCopyArea(fl_display,
- foreground,
- _window,
+ owner.getPixmap(),
+ owner.getWin(),
gc_copy,
x, y,
exp_width, exp_height,
- x+_offset_x, y+_offset_y);
+ x + owner.xpos(),
+ y + owner.ypos());
}
/* y1 is now the real beginning of row on the screen */
while (row != 0 && y < y2) {
-
text->GetVisibleRow(y, row, y + first);
y += row->height;
- row = row -> next;
-
+ row = row->next;
}
/* maybe we have to clear the screen at the bottom */
if (y < y2) {
- owner->painter().fillRectangle(0, y, _width, y2 - y,
+ owner.getPainter().fillRectangle(0, y,
+ owner.workWidth(),
+ y2 - y,
LColor::bottomarea);
}
}
{
long y = y_text - first;
- if (y + row->height > 0 && y - row->height <= _height) {
+ if (y + row->height > 0 && y - row->height <= owner.height()) {
/* ok there is something visible */
text->GetVisibleRow(y, row, y + first);
}
- y_text+= row->height;
+ y_text += row->height;
}
first = y;
/* is any optimiziation possible? */
- if ((y - old_first) < _height
- && (old_first - y) < _height) {
+ if ((y - old_first) < owner.height()
+ && (old_first - y) < owner.height()) {
if (first < old_first) {
DrawFromTo(0, old_first - first);
XCopyArea (fl_display,
- _window,
- _window,
+ owner.getWin(),
+ owner.getWin(),
gc_copy,
- _offset_x, _offset_y,
- _width , _height - old_first + first,
- _offset_x, _offset_y + old_first - first);
+ owner.xpos(),
+ owner.ypos(),
+ owner.workWidth(),
+ owner.height() - old_first + first,
+ owner.xpos(),
+ owner.ypos() + old_first - first
+ );
// expose the area drawn
- expose(0, 0, _width, old_first - first);
+ expose(0, 0,
+ owner.workWidth(),
+ old_first - first);
} else {
- DrawFromTo(_height + old_first - first, _height);
+ DrawFromTo(
+ owner.height() + old_first - first,
+ owner.height());
XCopyArea (fl_display,
- _window,
- _window,
+ owner.getWin(),
+ owner.getWin(),
gc_copy,
- _offset_x, _offset_y + first - old_first,
- _width , _height + old_first - first,
- _offset_x, _offset_y);
+ owner.xpos(),
+ owner.ypos() + first - old_first,
+ owner.workWidth(),
+ owner.height() + old_first - first,
+ owner.xpos(),
+ owner.ypos());
// expose the area drawn
- expose(0, _height + old_first - first,
- _width, first - old_first);
+ expose(0, owner.height() + old_first - first,
+ owner.workWidth(), first - old_first);
}
} else {
/* make a dumb new-draw */
- DrawFromTo(0, _height);
- expose(0, 0, _width, _height);
+ DrawFromTo(0, owner.height());
+ expose(0, 0, owner.workWidth(), owner.height());
}
}
void LyXScreen::ShowCursor()
{
- long x = 0;
- long y1 = 0;
- long y2 = 0;
-
if (cursor_visible) return;
- x = text->cursor.x;
+ long x = text->cursor.x;
- y1 = text->cursor.y - text->real_current_font.maxAscent() - first;
- if (y1 < 0) y1 = 0;
+ long y1 = max(text->cursor.y -
+ text->real_current_font.maxAscent() - first, 0L);
- y2 = text->cursor.y + text->real_current_font.maxDescent() - first;
- if (y2 > _height) y2 = _height;
+ long y2 = min(text->cursor.y +
+ text->real_current_font.maxDescent() - first,
+ long(owner.height()));
// Secure against very strange situations
if (y2 < y1) y2 = y1;
cursor_pixmap = 0;
}
- if (y2 > 0 && y1 < _height) {
+ if (y2 > 0 && y1 < owner.height()) {
cursor_pixmap_w = 1;
cursor_pixmap_h = y2 - y1 + 1;
cursor_pixmap_x = x;
cursor_pixmap_h,
fl_get_visual_depth());
XCopyArea(fl_display,
- _window,
+ owner.getWin(),
cursor_pixmap,
gc_copy,
- _offset_x + cursor_pixmap_x,
- _offset_y + cursor_pixmap_y,
+ owner.xpos() + cursor_pixmap_x,
+ owner.ypos() + cursor_pixmap_y,
cursor_pixmap_w, cursor_pixmap_h,
0, 0);
XDrawLine(fl_display,
- _window, gc_copy,
- x + _offset_x,
- y1 + _offset_y,
- x + _offset_x,
- y2 + _offset_y);
+ owner.getWin(),
+ gc_copy,
+ x + owner.xpos(),
+ y1 + owner.ypos(),
+ x + owner.xpos(),
+ y2 + owner.ypos());
cursor_visible = true;
}
}
{
long newtop = first;
- if (y + desc - first >= _height)
- newtop = y - 3*_height / 4; /* the scroll region must be so big!! */
+ if (y + desc - first >= owner.height())
+ newtop = y - 3 * owner.height() / 4; /* the scroll region must be so big!! */
else if (y - asc < first
&& first > 0) {
- newtop = y - _height / 4;
+ newtop = y - owner.height() / 4;
}
if (newtop < 0)
newtop = 0;
}
-void LyXScreen::HideManualCursor()
-{
- HideCursor();
-}
-
-
void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc)
{
- long y1 = 0;
- long y2 = 0;
-
- y1 = y - first - asc;
- if (y1 < 0)
- y1 = 0;
- y2 = y -first + desc;
- if (y2 > _height)
- y2 = _height;
+ long y1 = max(y - first - asc, 0L);
+ long y2 = min(y - first + desc, long(owner.height()));
if (cursor_pixmap){
XFreePixmap(fl_display, cursor_pixmap);
cursor_pixmap = 0;
}
- if (y2 > 0 && y1 < _height) {
+ if (y2 > 0 && y1 <
+ owner.height()) {
cursor_pixmap_w = 1;
cursor_pixmap_h = y2 - y1 + 1;
cursor_pixmap_x = x,
cursor_pixmap_h,
fl_get_visual_depth());
XCopyArea (fl_display,
- _window,
+ owner.getWin(),
cursor_pixmap,
gc_copy,
- _offset_x + cursor_pixmap_x,
- _offset_y + cursor_pixmap_y,
+ owner.xpos() + cursor_pixmap_x,
+ owner.ypos() + cursor_pixmap_y,
cursor_pixmap_w,
cursor_pixmap_h,
0, 0);
XDrawLine(fl_display,
- _window, gc_copy,
- x+_offset_x,
- y1+_offset_y,
- x+_offset_x,
- y2+_offset_y);
+ owner.getWin(),
+ gc_copy,
+ x + owner.xpos(),
+ y1 + owner.ypos(),
+ x + owner.xpos(),
+ y2 + owner.ypos());
}
cursor_visible = true;
}
if (cursor_pixmap){
XCopyArea (fl_display,
cursor_pixmap,
- _window,
+ owner.getWin(),
gc_copy,
0, 0,
cursor_pixmap_w, cursor_pixmap_h,
- cursor_pixmap_x + _offset_x,
- cursor_pixmap_y + _offset_y);
+ cursor_pixmap_x + owner.xpos(),
+ cursor_pixmap_y + owner.ypos());
}
cursor_visible = false;
}
if (text->cursor.y
- text->cursor.row->baseline
+ text->cursor.row->height
- - first >= _height) {
- if (text->cursor.row->height < _height
- && text->cursor.row->height > _height/4)
+ - first >= owner.height()) {
+ if (text->cursor.row->height < owner.height()
+ && text->cursor.row->height > owner.height() / 4)
newtop = text->cursor.y
+ text->cursor.row->height
- - text->cursor.row->baseline - _height;
+ - text->cursor.row->baseline - owner.height();
else
newtop = text->cursor.y
- - 3*_height / 4; /* the scroll region must be so big!! */
+ - 3 * owner.height() / 4; /* the scroll region must be so big!! */
} else if (text->cursor.y - text->cursor.row->baseline < first
&& first > 0) {
- if (text->cursor.row->height < _height
- && text->cursor.row->height > _height/4)
+ if (text->cursor.row->height < owner.height()
+ && text->cursor.row->height > owner.height() / 4)
newtop = text->cursor.y - text->cursor.row->baseline;
else {
- newtop = text->cursor.y - _height / 4;
+ newtop = text->cursor.y - owner.height() / 4;
if (newtop > first)
newtop = first;
}
void LyXScreen::Update()
{
- long y = 0;
-
if (text->status == LyXText::NEED_MORE_REFRESH
|| screen_refresh_y > -1 ) {
+ long y = 0;
if (screen_refresh_y > -1
&& screen_refresh_y < text->refresh_y)
y = screen_refresh_y;
if (y < first) y = first;
- DrawFromTo(y - first, _height);
+ DrawFromTo(y - first, owner.height());
text->refresh_y = 0;
text->status = LyXText::UNCHANGED;
screen_refresh_y = -1;
- expose(0, y-first, _width, _height - (y - first));
+ expose(0, y - first,
+ owner.workWidth(), owner.height() - (y - first));
} else if (text->status == LyXText::NEED_VERY_LITTLE_REFRESH) {
/* ok I will update the current cursor row */
- y = text->refresh_y;
+ long y = text->refresh_y;
DrawOneRow(text->refresh_row, y);
text->status = LyXText::UNCHANGED;
- expose(0, text->refresh_y-first,
- _width, text->refresh_row->height);
+ expose(0, text->refresh_y - first,
+ owner.workWidth(), text->refresh_row->height);
}
}
void LyXScreen::SmallUpdate()
{
- Row * row = 0;
- long y = 0;
- long y2 = 0;
-
- if (text->status == LyXText::NEED_MORE_REFRESH){
+ if (text->status == LyXText::NEED_MORE_REFRESH) {
/* ok I will update till the current cursor row */
- row = text->refresh_row;
- y = text->refresh_y;
- y2 = y;
+ Row * row = text->refresh_row;
+ long y = text->refresh_y;
+ long y2 = y;
if (y > text->cursor.y) {
Update();
return;
}
- while (row && row != text->cursor.row && y < first + _height) {
+ while (row
+ && row != text->cursor.row
+ && y < first + owner.height()) {
DrawOneRow(row, y);
row = row->next;
}
screen_refresh_row = row->next;
text->status = LyXText::UNCHANGED;
// Is the right regin exposed?
- expose(0, y2-first, _width, y-y2);
+ expose(0, y2 - first,
+ owner.workWidth(), y - y2);
} else if (text->status == LyXText::NEED_VERY_LITTLE_REFRESH) {
/* ok I will update the current cursor row */
- row = text->refresh_row;
- y = text->refresh_y;
- DrawOneRow(row, y);
+ long y = text->refresh_y;
+ DrawOneRow(text->refresh_row, y);
text->status = LyXText::UNCHANGED;
expose(0, text->refresh_y - first,
- _width, row->height);
+ owner.workWidth(), text->refresh_row->height);
}
}
void LyXScreen::ToggleSelection(bool kill_selection)
{
/* only if there is a selection */
- if (!text->selection)
- return;
+ if (!text->selection) return;
long top = text->sel_start_cursor.y
- text->sel_start_cursor.row->baseline;
long bottom = text->sel_end_cursor.y
- text->sel_end_cursor.row->baseline
+ text->sel_end_cursor.row->height;
+
+ if (top < first)
+ top = max(top, first);
+ if (bottom < first)
+ bottom = max(bottom, first);
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
-
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
-
+ if (bottom > first + owner.height())
+ bottom = first + owner.height();
+ if (top > first + owner.height())
+ top = first + owner.height();
+
if (kill_selection)
text->selection = 0;
DrawFromTo(top - first, bottom - first);
- expose(0, top - first, _width, bottom - first - (top - first));
+ expose(0, top - first,
+ owner.workWidth(),
+ bottom - first - (top - first));
}
if (bottom - first < 0)
bottom = first;
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
+ if (bottom - first > owner.height())
+ bottom = first + owner.height();
+ if (top - first > owner.height())
+ top = first + owner.height();
DrawFromTo(top - first, bottom - first);
- expose(0, top - first, _width, bottom - first - (top - first));
+ expose(0, top - first, owner.workWidth(),
+ bottom - first - (top - first));
}
#include "lyxparagraph.h"
#include "lyxtext.h"
#include "support/textutils.h"
+#include "insets/insetbib.h"
#include "lyx_gui_misc.h"
#include "gettext.h"
#include "bufferparams.h"
#include "LString.h"
#include "lyxparagraph.h"
#include "insets/inseterror.h"
+#include "insets/insetbib.h"
#include "layout.h"
#include "LyXView.h"
#include "support/textutils.h"