Remove redundant code and introduce InsetCollapsable::setLabelColor().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21380 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-02 16:46:48 +00:00
parent 876d88a86e
commit 12a3c703d1
9 changed files with 24 additions and 44 deletions

View File

@ -142,10 +142,6 @@ void InsetBox::read(Buffer const & buf, Lexer & lex)
void InsetBox::setButtonLabel()
{
FontInfo font = sane_font;
font.decSize();
font.decSize();
BoxType btype = boxtranslator().find(params_.type);
docstring label;
@ -162,8 +158,7 @@ void InsetBox::setButtonLabel()
setLabel(label);
font.setColor(Color_foreground);
setLabelFont(font);
setLabelColor(Color_foreground);
}

View File

@ -72,6 +72,8 @@ public:
///
void setLabelFont(FontInfo const & f);
///
void setLabelColor(ColorCode code);
///
bool isOpen() const { return geometry() != ButtonOnly; }
///
CollapseStatus status() const;

View File

@ -52,7 +52,6 @@ using std::string;
void InsetERT::init()
{
setButtonLabel();
// FIXME: what to do with those?
//text_.current_font.setLanguage(latex_language);
//text_.real_current_font.setLanguage(latex_language);

View File

@ -115,11 +115,6 @@ InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
: InsetCollapsable(bp), name_(from_utf8(type))
{
setLabel(_("float: ") + floatName(type, bp));
FontInfo font = sane_font;
font.decSize();
font.decSize();
font.setColor(Color_collapsable);
setLabelFont(font);
params_.type = type;
}

View File

@ -65,28 +65,36 @@ docstring const InsetHyperlink::getScreenLabel(Buffer const &) const
}
static void replaceAny(docstring & s, docstring const & items,
docstring const & replacement)
{
if (s.empty())
return;
size_t i = 0;
while (i < s.size()) {
if ((i = s.find_first_of(items, i)) == string::npos)
break;
s.insert(i, replacement);
i += 2;
}
}
int InsetHyperlink::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
docstring url = getParam("target");
static docstring const backslash = from_ascii("\\");
static docstring const braces = from_ascii("{}");
static char_type const chars_url[2] = {'%', '#'};
static char_type const chars_name[6] = {
'&', '_', '$', '%', '#', '^'};
// The characters in chars_url[] need to be changed to a command when
// they are in the url field.
if (!url.empty()) {
// the chars_url[] characters must be handled for both, url and href
for (int k = 0; k < 2; k++) {
for (size_t i = 0, pos;
(pos = url.find(chars_url[k], i)) != string::npos;
i = pos + 2) {
url.replace(pos, 1, backslash + chars_url[k]);
}
}
} // end if (!url.empty())
static docstring const chars_url = from_ascii("%#");
replaceAny(url, chars_url, backslash);
docstring name = getParam("name");

View File

@ -48,11 +48,8 @@ char const lstinline_delimiters[] =
void InsetListings::init()
{
setButtonLabel();
FontInfo font = sane_font;
font.decSize();
font.decSize();
font.setColor(Color_none);
setLabelFont(font);
layout_.labelfont.setColor(Color_none);
// FIXME: what to do with those?
//text_.current_font.setLanguage(latex_language);
//text_.real_current_font.setLanguage(latex_language);

View File

@ -24,9 +24,6 @@ namespace lyx {
InsetOptArg::InsetOptArg(BufferParams const & ins)
: InsetCollapsable(ins)
{
FontInfo font = sane_font;
font.setColor(Color_collapsable);
setLabelFont(font);
setLabel(_("opt"));
}
@ -34,9 +31,6 @@ InsetOptArg::InsetOptArg(BufferParams const & ins)
InsetOptArg::InsetOptArg(InsetOptArg const & in)
: InsetCollapsable(in)
{
FontInfo font = sane_font;
font.setColor(Color_collapsable);
setLabelFont(font);
setLabel(_("opt"));
}

View File

@ -40,11 +40,6 @@ Inset.heorem::InsetTheorem()
: InsetCollapsable()
{
setLabel(_("theorem"));
FontInfo font = sane_font;
font.decSize();
font.decSize();
font.setColor(Color_collapsable);
setLabelFont(font);
#if 0
setAutoCollapse(false);
#endif

View File

@ -47,11 +47,6 @@ InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
: InsetCollapsable(bp), name_(from_utf8(type))
{
setLabel(_("wrap: ") + floatName(type, bp));
FontInfo font = sane_font;
font.decSize();
font.decSize();
font.setColor(Color_collapsable);
setLabelFont(font);
params_.type = type;
params_.lines = 0;
params_.placement = "o";