mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Once again the user can use the Font button on the toolbar to get the current
contents of the character dialog even if the dialog is hidden. I think that the functionality of the character dialog/Font button on the toolbar is now as it was in 1.1.6. Oh, but we now have a working button controller that the GUI's get for free... Keep up the bug reports! Angus git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2114 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3f11b9242b
commit
3e22b13963
@ -1,3 +1,16 @@
|
||||
2001-06-13 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* ControlDialogs.h added // -*- C++ -*-
|
||||
|
||||
* ControlCharacter.[Ch]: added // -*- C++ -*-
|
||||
(setParams): Check contents of font_ to activate Apply button.
|
||||
(clearParams): removed.
|
||||
font_ is now stored as a boost::scoped_ptr.
|
||||
font_ is no longer deleted on hide(), so it's contents can now be used
|
||||
by the Font button on the toolbar.
|
||||
Lots of new methods so that the GUI can easily get the contents of
|
||||
font_ when it update()s.
|
||||
|
||||
2001-06-12 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* ControlCharacter.C (apply): test that font_ exists, thereby preventing
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlCharacter.C
|
||||
* Copyright 2001 The LyX Team.
|
||||
@ -40,54 +41,106 @@ ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
|
||||
|
||||
void ControlCharacter::setParams()
|
||||
{
|
||||
if (font_) delete font_;
|
||||
font_ = new LyXFont(LyXFont::ALL_IGNORE);
|
||||
}
|
||||
// Do this the first time only. Used as a flag for whether or not the
|
||||
// view has been built
|
||||
if (!font_.get())
|
||||
font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
|
||||
|
||||
|
||||
void ControlCharacter::clearParams()
|
||||
{
|
||||
if (font_) {
|
||||
delete font_;
|
||||
font_ = 0;
|
||||
}
|
||||
// so that the user can press Ok
|
||||
if (getFamily() != LyXFont::IGNORE_FAMILY ||
|
||||
getSeries() != LyXFont::IGNORE_SERIES ||
|
||||
getShape() != LyXFont::IGNORE_SHAPE ||
|
||||
getSize() != LyXFont::IGNORE_SIZE ||
|
||||
getBar() != character::IGNORE ||
|
||||
getColor() != LColor::ignore ||
|
||||
font_->language() != ignore_language)
|
||||
bc().valid();
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::apply()
|
||||
{
|
||||
if (!(font_ && lv_.view()->available()))
|
||||
// Nothing to apply. (Can be called from the Toolbar.)
|
||||
if (!font_.get())
|
||||
return;
|
||||
|
||||
view().apply();
|
||||
|
||||
ToggleAndShow(lv_.view(), *font_, toggleall_);
|
||||
// Apply from the view if it's visible. Otherwise, use the stored values
|
||||
if (lv_.view()->available())
|
||||
view().apply();
|
||||
|
||||
ToggleAndShow(lv_.view(), *(font_.get()), toggleall_);
|
||||
lv_.view()->setState();
|
||||
lv_.buffer()->markDirty();
|
||||
setMinibuffer(&lv_, _("Character set"));
|
||||
}
|
||||
|
||||
|
||||
LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
|
||||
{
|
||||
if (font_.get())
|
||||
return font_->family();
|
||||
return LyXFont::IGNORE_FAMILY;
|
||||
}
|
||||
|
||||
void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
|
||||
{
|
||||
font_->setFamily(val);
|
||||
}
|
||||
|
||||
LyXFont::FONT_SERIES ControlCharacter::getSeries() const
|
||||
{
|
||||
if (font_.get())
|
||||
return font_->series();
|
||||
return LyXFont::IGNORE_SERIES;
|
||||
}
|
||||
|
||||
void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
|
||||
{
|
||||
font_->setSeries(val);
|
||||
}
|
||||
|
||||
LyXFont::FONT_SHAPE ControlCharacter::getShape() const
|
||||
{
|
||||
if (font_.get())
|
||||
return font_->shape();
|
||||
return LyXFont::IGNORE_SHAPE;
|
||||
}
|
||||
|
||||
void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
|
||||
{
|
||||
font_->setShape(val);
|
||||
}
|
||||
|
||||
LyXFont::FONT_SIZE ControlCharacter::getSize() const
|
||||
{
|
||||
if (font_.get())
|
||||
return font_->size();
|
||||
return LyXFont::IGNORE_SIZE;
|
||||
}
|
||||
|
||||
void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
|
||||
{
|
||||
font_->setSize(val);
|
||||
}
|
||||
|
||||
character::FONT_STATE ControlCharacter::getBar() const
|
||||
{
|
||||
if (font_.get()) {
|
||||
if (font_->emph() != LyXFont::IGNORE)
|
||||
return character::EMPH_TOGGLE;
|
||||
|
||||
else if (font_->underbar() != LyXFont::IGNORE)
|
||||
return character::UNDERBAR_TOGGLE;
|
||||
|
||||
else if (font_->noun() != LyXFont::IGNORE)
|
||||
return character::NOUN_TOGGLE;
|
||||
|
||||
else if (font_->latex() != LyXFont::IGNORE)
|
||||
return character::LATEX_TOGGLE;
|
||||
}
|
||||
return character::IGNORE;
|
||||
}
|
||||
|
||||
void ControlCharacter::setBar(character::FONT_STATE val)
|
||||
{
|
||||
switch (val) {
|
||||
@ -123,6 +176,33 @@ void ControlCharacter::setBar(character::FONT_STATE val)
|
||||
}
|
||||
}
|
||||
|
||||
LColor::color ControlCharacter::getColor() const
|
||||
{
|
||||
LColor::color col = LColor::ignore;
|
||||
|
||||
if (font_.get()) {
|
||||
switch (font_->color()) {
|
||||
case LColor::ignore:
|
||||
case LColor::none:
|
||||
case LColor::black:
|
||||
case LColor::white:
|
||||
case LColor::red:
|
||||
case LColor::green:
|
||||
case LColor::blue:
|
||||
case LColor::cyan:
|
||||
case LColor::magenta:
|
||||
case LColor::yellow:
|
||||
case LColor::inherit:
|
||||
break;
|
||||
default:
|
||||
col = font_->color();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
void ControlCharacter::setColor(LColor::color val)
|
||||
{
|
||||
switch (val) {
|
||||
@ -139,13 +219,20 @@ void ControlCharacter::setColor(LColor::color val)
|
||||
case LColor::inherit:
|
||||
font_->setColor(val);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
string ControlCharacter::getLanguage() const
|
||||
{
|
||||
if (font_.get() && font_->language())
|
||||
return font_->language()->lang();
|
||||
return _("No change");
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::setLanguage(string const & val)
|
||||
{
|
||||
if (val == _("No change"))
|
||||
@ -158,6 +245,12 @@ void ControlCharacter::setLanguage(string const & val)
|
||||
font_->setLanguage(languages.getLanguage(val));
|
||||
}
|
||||
|
||||
|
||||
bool ControlCharacter::getToggleAll() const
|
||||
{
|
||||
return toggleall_;
|
||||
}
|
||||
|
||||
void ControlCharacter::setToggleAll(bool t)
|
||||
{
|
||||
toggleall_ = t;
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlCharacter.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
@ -9,6 +10,8 @@
|
||||
#ifndef CONTROLCHARACTER_H
|
||||
#define CONTROLCHARACTER_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
@ -41,16 +44,31 @@ public:
|
||||
///
|
||||
void setToggleAll(bool);
|
||||
|
||||
///
|
||||
LyXFont::FONT_FAMILY getFamily() const;
|
||||
///
|
||||
LyXFont::FONT_SERIES getSeries() const;
|
||||
///
|
||||
LyXFont::FONT_SHAPE getShape() const;
|
||||
///
|
||||
LyXFont::FONT_SIZE getSize() const;
|
||||
///
|
||||
character::FONT_STATE getBar() const;
|
||||
///
|
||||
LColor::color getColor() const;
|
||||
///
|
||||
string getLanguage() const;
|
||||
///
|
||||
bool getToggleAll() const;
|
||||
|
||||
private:
|
||||
/// Get changed parameters and Dispatch them to the kernel.
|
||||
virtual void apply();
|
||||
/// set the params before show or update.
|
||||
virtual void setParams();
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
|
||||
///
|
||||
LyXFont * font_;
|
||||
boost::scoped_ptr<LyXFont> font_;
|
||||
///
|
||||
bool toggleall_;
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
|
@ -1,3 +1,9 @@
|
||||
2001-06-13 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormCharacter.[Ch]: added // -*- C++ -*-
|
||||
* FormCharacter.C (update): now uses contents of font_, stored
|
||||
permanently by the controller to update() the dialog.
|
||||
|
||||
2001-06-12 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormInclude.C:
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormCharacter.C
|
||||
* Copyright 2001 The LyX Team.
|
||||
@ -137,11 +138,43 @@ void FormCharacter::apply()
|
||||
controller().setToggleAll(toggleall);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template<class A>
|
||||
typename vector<A>::size_type findPos(vector<A> const & vec, A const & val)
|
||||
{
|
||||
vector<A>::const_iterator it =
|
||||
std::find(vec.begin(), vec.end(), val);
|
||||
if (it == vec.end())
|
||||
return 0;
|
||||
return it - vec.begin();
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
void FormCharacter::update()
|
||||
{
|
||||
if (input(0,0) == ButtonPolicy::SMI_VALID)
|
||||
bc().valid(); // so that the user can press Ok
|
||||
int pos = int(findPos(family_, controller().getFamily()));
|
||||
fl_set_choice(dialog_->choice_family, pos+1);
|
||||
|
||||
pos = int(findPos(series_, controller().getSeries()));
|
||||
fl_set_choice(dialog_->choice_series, pos+1);
|
||||
|
||||
pos = int(findPos(shape_, controller().getShape()));
|
||||
fl_set_choice(dialog_->choice_shape, pos+1);
|
||||
|
||||
pos = int(findPos(size_, controller().getSize()));
|
||||
fl_set_choice(dialog_->choice_size, pos+1);
|
||||
|
||||
pos = int(findPos(bar_, controller().getBar()));
|
||||
fl_set_choice(dialog_->choice_bar, pos+1);
|
||||
|
||||
pos = int(findPos(color_, controller().getColor()));
|
||||
fl_set_choice(dialog_->choice_color, pos+1);
|
||||
|
||||
combo_language2_->select_text(controller().getLanguage());
|
||||
|
||||
fl_set_button(dialog_->check_toggle_all, controller().getToggleAll());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormCharacter.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
|
Loading…
Reference in New Issue
Block a user