mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
fileformat change: support to specify a document-wide font color
- new buffer parameter \fontcolor - the default color is internally black because we have to set a color - the font color is only used when the user explicitly specified a color git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34042 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d2a13b5a9a
commit
4e2cd30657
@ -7,12 +7,16 @@ The good example would be 2010-01-10 entry.
|
||||
|
||||
-----------------------
|
||||
|
||||
2010-04-03 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 384: support to specify a document-wide
|
||||
font color: new buffer parameter \fontcolor
|
||||
|
||||
2010-03-31 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 383: support for Turkmen
|
||||
|
||||
2010-03-31 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 382: support to change the font color
|
||||
for greyed-out notes: new parameter \notefontcolor
|
||||
for greyed-out notes: new buffer parameter \notefontcolor
|
||||
|
||||
2010-03-28: Vincent van Ravesteijn <vfr@lyx.org>
|
||||
* Format incremented to 381: support for new parameters
|
||||
|
@ -1393,6 +1393,44 @@ def revert_turkmen(document):
|
||||
j = j + 1
|
||||
|
||||
|
||||
def revert_fontcolor(document):
|
||||
" Reverts font color to preamble code "
|
||||
i = 0
|
||||
colorcode = ""
|
||||
while True:
|
||||
i = find_token(document.header, "\\fontcolor", i)
|
||||
if i == -1:
|
||||
return
|
||||
colorcode = get_value(document.header, '\\fontcolor', 0)
|
||||
del document.header[i]
|
||||
# don't clutter the preamble if backgroundcolor is not set
|
||||
if colorcode == "#000000":
|
||||
continue
|
||||
# the color code is in the form #rrggbb where every character denotes a hex number
|
||||
# convert the string to an int
|
||||
red = string.atoi(colorcode[1:3],16)
|
||||
# we want the output "0.5" for the value "127" therefore add here
|
||||
if red != 0:
|
||||
red = red + 1
|
||||
redout = float(red) / 256
|
||||
green = string.atoi(colorcode[3:5],16)
|
||||
if green != 0:
|
||||
green = green + 1
|
||||
greenout = float(green) / 256
|
||||
blue = string.atoi(colorcode[5:7],16)
|
||||
if blue != 0:
|
||||
blue = blue + 1
|
||||
blueout = float(blue) / 256
|
||||
# write the preamble
|
||||
insert_to_preamble(0, document,
|
||||
'% Commands inserted by lyx2lyx to set the font color\n'
|
||||
+ '\\@ifundefined{definecolor}{\\usepackage{color}}{}\n'
|
||||
+ '\\definecolor{document_fontcolor}{rgb}{'
|
||||
+ str(redout) + ', ' + str(greenout)
|
||||
+ ', ' + str(blueout) + '}\n'
|
||||
+ '\\color{document_fontcolor}\n')
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1435,10 +1473,12 @@ convert = [[346, []],
|
||||
[380, []],
|
||||
[381, []],
|
||||
[382, []],
|
||||
[383, []]
|
||||
[383, []],
|
||||
[384, []]
|
||||
]
|
||||
|
||||
revert = [[382, [revert_turkmen]],
|
||||
revert = [[383, [revert_fontcolor]],
|
||||
[382, [revert_turkmen]],
|
||||
[381, [revert_notefontcolor]],
|
||||
[380, [revert_equalspacing_xymatrix]],
|
||||
[379, [revert_inset_preview]],
|
||||
|
@ -126,7 +126,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 383; // uwestoehr: support for Turkmen
|
||||
int const LYX_FORMAT = 384; // uwestoehr: support for document-wide font color
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
@ -668,6 +668,8 @@ int Buffer::readHeader(Lexer & lex)
|
||||
params().pdfoptions().clear();
|
||||
params().indiceslist().clear();
|
||||
params().backgroundcolor = lyx::rgbFromHexName("#ffffff");
|
||||
params().fontcolor = lyx::rgbFromHexName("#000000");
|
||||
params().isfontcolor = false;
|
||||
params().notefontcolor = lyx::rgbFromHexName("#cccccc");
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
@ -369,6 +369,9 @@ BufferParams::BufferParams()
|
||||
suppress_date = false;
|
||||
// white is equal to no background color
|
||||
backgroundcolor = lyx::rgbFromHexName("#ffffff");
|
||||
// no color is the default (black)
|
||||
fontcolor = lyx::rgbFromHexName("#000000");
|
||||
isfontcolor = false;
|
||||
// light gray is the default font color for greyed-out notes
|
||||
notefontcolor = lyx::rgbFromHexName("#cccccc");
|
||||
compressed = lyxrc.save_compressed;
|
||||
@ -723,6 +726,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
} else if (token == "\\backgroundcolor") {
|
||||
lex.eatLine();
|
||||
backgroundcolor = lyx::rgbFromHexName(lex.getString());
|
||||
} else if (token == "\\fontcolor") {
|
||||
lex.eatLine();
|
||||
fontcolor = lyx::rgbFromHexName(lex.getString());
|
||||
isfontcolor = true;
|
||||
} else if (token == "\\notefontcolor") {
|
||||
lex.eatLine();
|
||||
string color = lex.getString();
|
||||
@ -921,6 +928,8 @@ void BufferParams::writeFile(ostream & os) const
|
||||
<< '\n';
|
||||
if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
|
||||
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
|
||||
if (isfontcolor == true)
|
||||
os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
|
||||
if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
|
||||
os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
|
||||
|
||||
@ -1454,6 +1463,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
features.require("pagecolor");
|
||||
}
|
||||
|
||||
// only output when the font color is not black
|
||||
if (isfontcolor == true) {
|
||||
// only require color here, the font color will be defined
|
||||
// in LaTeXFeatures.cpp to avoid interferences with the LaTeX
|
||||
// package pdfpages
|
||||
features.require("color");
|
||||
features.require("fontcolor");
|
||||
}
|
||||
|
||||
// Only if class has a ToC hierarchy
|
||||
if (tclass.hasTocLevels()) {
|
||||
if (secnumdepth != tclass.secnumdepth()) {
|
||||
|
@ -286,6 +286,10 @@ public:
|
||||
///
|
||||
RGBColor backgroundcolor;
|
||||
///
|
||||
RGBColor fontcolor;
|
||||
///
|
||||
bool isfontcolor;
|
||||
///
|
||||
RGBColor notefontcolor;
|
||||
/// \param index should lie in the range 0 <= \c index <= 3.
|
||||
Bullet & temp_bullet(size_type index);
|
||||
|
@ -590,11 +590,18 @@ string const LaTeXFeatures::getColorOptions() const
|
||||
colors << "\\pagecolor{page_backgroundcolor}\n";
|
||||
}
|
||||
|
||||
if (mustProvide("fontcolor")) {
|
||||
colors << "\\definecolor{document_fontcolor}{rgb}{";
|
||||
colors << outputLaTeXColor(params_.fontcolor) << "}\n";
|
||||
// set the color
|
||||
colors << "\\color{document_fontcolor}\n";
|
||||
}
|
||||
|
||||
if (mustProvide("lyxgreyedout")) {
|
||||
colors << "\\definecolor{note_fontcolor}{rgb}{";
|
||||
colors << outputLaTeXColor(params_.notefontcolor) << "}\n";
|
||||
// the color will be set together with the definition of
|
||||
// the lyxgreyedout environment (lyxgreyedout_def)
|
||||
// the lyxgreyedout environment (see lyxgreyedout_def)
|
||||
}
|
||||
|
||||
return colors.str();
|
||||
|
@ -178,6 +178,8 @@ vector<pair<string, QString> > pagestyles;
|
||||
namespace lyx {
|
||||
|
||||
RGBColor set_backgroundcolor;
|
||||
RGBColor set_fontcolor;
|
||||
bool is_fontcolor;
|
||||
RGBColor set_notefontcolor;
|
||||
|
||||
namespace {
|
||||
@ -874,6 +876,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
|
||||
// color
|
||||
colorModule = new UiWidget<Ui::ColorUi>;
|
||||
connect(colorModule->fontColorPB, SIGNAL(clicked()),
|
||||
this, SLOT(changeFontColor()));
|
||||
connect(colorModule->delFontColorTB, SIGNAL(clicked()),
|
||||
this, SLOT(deleteFontColor()));
|
||||
connect(colorModule->noteFontColorPB, SIGNAL(clicked()),
|
||||
this, SLOT(changeNoteFontColor()));
|
||||
connect(colorModule->delNoteFontColorTB, SIGNAL(clicked()),
|
||||
@ -1373,6 +1379,36 @@ void GuiDocument::deleteBackgroundColor()
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::changeFontColor()
|
||||
{
|
||||
QColor const & newColor = QColorDialog::getColor(
|
||||
rgb2qcolor(set_fontcolor), asQWidget());
|
||||
if (!newColor.isValid())
|
||||
return;
|
||||
// set the button color and text
|
||||
colorModule->fontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(newColor));
|
||||
colorModule->fontColorPB->setText(toqstr("Change..."));
|
||||
// save color
|
||||
set_fontcolor = rgbFromHexName(fromqstr(newColor.name()));
|
||||
is_fontcolor = true;
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::deleteFontColor()
|
||||
{
|
||||
// set the button color back to default by setting an epmty StyleSheet
|
||||
colorModule->fontColorPB->setStyleSheet(QLatin1String(""));
|
||||
// change button text
|
||||
colorModule->fontColorPB->setText(toqstr("Default..."));
|
||||
// save default color (black)
|
||||
set_fontcolor = rgbFromHexName("#000000");
|
||||
is_fontcolor = false;
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::changeNoteFontColor()
|
||||
{
|
||||
QColor const & newColor = QColorDialog::getColor(
|
||||
@ -2006,6 +2042,8 @@ void GuiDocument::applyView()
|
||||
|
||||
//color
|
||||
bp_.backgroundcolor = set_backgroundcolor;
|
||||
bp_.fontcolor = set_fontcolor;
|
||||
bp_.isfontcolor = is_fontcolor;
|
||||
bp_.notefontcolor = set_notefontcolor;
|
||||
|
||||
// numbering
|
||||
@ -2391,9 +2429,17 @@ void GuiDocument::paramsToDialog()
|
||||
langModule->otherencodingRB->setChecked(!default_enc);
|
||||
|
||||
//color
|
||||
if (bp_.isfontcolor) {
|
||||
colorModule->fontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(rgb2qcolor(bp_.fontcolor)));
|
||||
}
|
||||
set_fontcolor = bp_.fontcolor;
|
||||
is_fontcolor = bp_.isfontcolor;
|
||||
|
||||
colorModule->noteFontColorPB->setStyleSheet(
|
||||
colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
|
||||
set_notefontcolor = bp_.notefontcolor;
|
||||
|
||||
colorModule->backgroundPB->setStyleSheet(
|
||||
colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
|
||||
set_backgroundcolor = bp_.backgroundcolor;
|
||||
|
@ -109,6 +109,8 @@ private Q_SLOTS:
|
||||
void modulesChanged();
|
||||
void changeBackgroundColor();
|
||||
void deleteBackgroundColor();
|
||||
void changeFontColor();
|
||||
void deleteFontColor();
|
||||
void changeNoteFontColor();
|
||||
void deleteNoteFontColor();
|
||||
void xetexChanged(bool);
|
||||
|
@ -29,14 +29,82 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="fontColorLA">
|
||||
<property name="text">
|
||||
<string>Font color:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fontColorPB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="fontColorPB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click to change the color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="delFontColorTB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>23</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert the color to the default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R&eset</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::LeftArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="noteFontColorLA">
|
||||
<property name="text">
|
||||
<string>Font color for
|
||||
greyed-out notes:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fontColorPB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="noteFontColorPB">
|
||||
|
Loading…
Reference in New Issue
Block a user