* src/insets/InsetListings.{cpp,h}:

- implement metrics and draw, fix font initialization
	(fix bug 3653)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18429 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-05-20 05:53:49 +00:00
parent e658f71f07
commit 5cb3e19200
2 changed files with 34 additions and 10 deletions

View File

@ -19,6 +19,7 @@
#include "DispatchResult.h" #include "DispatchResult.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "FuncStatus.h" #include "FuncStatus.h"
#include "MetricsInfo.h"
#include "Cursor.h" #include "Cursor.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -38,18 +39,13 @@ using std::string;
void InsetListings::init() void InsetListings::init()
{ {
setButtonLabel(); setButtonLabel();
// FIXME: define Color::listing?
Font font(Font::ALL_SANE); Font font(Font::ALL_SANE);
font.decSize(); font.decSize();
font.decSize(); font.decSize();
font.setColor(Color::foreground); font.setColor(Color::none);
setLabelFont(font); setLabelFont(font);
// FIXME: english_language? text_.current_font.setLanguage(latex_language);
text_.current_font.setLanguage(english_language); text_.real_current_font.setLanguage(latex_language);
text_.real_current_font.setLanguage(english_language);
// FIXME: why I can not make text of source code black with the following two lines?
text_.current_font.setColor(Color::foreground);
text_.real_current_font.setColor(Color::foreground);
} }
@ -119,7 +115,7 @@ void InsetListings::read(Buffer const & buf, Lexer & lex)
break; break;
} }
} }
InsetCollapsable::read(buf, lex); InsetERT::read(buf, lex);
} }
@ -239,6 +235,29 @@ void InsetListings::setButtonLabel()
} }
bool InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font tmpfont = mi.base.font;
getDrawFont(mi.base.font);
mi.base.font.realize(tmpfont);
InsetCollapsable::metrics(mi, dim);
mi.base.font = tmpfont;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}
void InsetListings::draw(PainterInfo & pi, int x, int y) const
{
Font tmpfont = pi.base.font;
getDrawFont(pi.base.font);
pi.base.font.realize(tmpfont);
InsetCollapsable::draw(pi, x, y);
pi.base.font = tmpfont;
}
void InsetListings::validate(LaTeXFeatures & features) const void InsetListings::validate(LaTeXFeatures & features) const
{ {
features.require("listings"); features.require("listings");
@ -255,8 +274,9 @@ bool InsetListings::showInsetDialog(BufferView * bv) const
void InsetListings::getDrawFont(Font & font) const void InsetListings::getDrawFont(Font & font) const
{ {
font = Font(Font::ALL_INHERIT, english_language); font = Font(Font::ALL_INHERIT, latex_language);
font.setFamily(Font::TYPEWRITER_FAMILY); font.setFamily(Font::TYPEWRITER_FAMILY);
// FIXME: define Color::listing?
font.setColor(Color::foreground); font.setColor(Color::foreground);
} }

View File

@ -47,6 +47,10 @@ public:
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///
bool metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
bool showInsetDialog(BufferView *) const; bool showInsetDialog(BufferView *) const;
/// ///
void getDrawFont(Font &) const; void getDrawFont(Font &) const;