mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Remove the XForms frontend, update the autotools files, and fixup po.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14320 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0c0c43b8eb
commit
22861453fe
@ -4,7 +4,7 @@ ACLOCAL="aclocal -I ${PWD}/m4"
|
||||
AUTOHEADER="autoheader"
|
||||
AUTOMAKE="automake --add-missing --copy --foreign"
|
||||
AUTOCONF="autoconf"
|
||||
ACINCLUDE_FILES="lyxinclude.m4 libtool.m4 xforms.m4 qt.m4 gtk--.m4 gnome--.m4 gnome.m4 spell.m4 pkg.m4"
|
||||
ACINCLUDE_FILES="lyxinclude.m4 libtool.m4 qt.m4 gtk--.m4 gnome--.m4 gnome.m4 spell.m4 pkg.m4"
|
||||
|
||||
# Discover what version of automake we are using.
|
||||
automake_version=`$AUTOMAKE --version 2>/dev/null | head -n 1`
|
||||
|
@ -10,5 +10,4 @@ EXTRA_DIST = \
|
||||
lyxinclude.m4 \
|
||||
pkg.m4 \
|
||||
qt.m4 \
|
||||
spell.m4 \
|
||||
xforms.m4
|
||||
spell.m4
|
||||
|
147
config/xforms.m4
147
config/xforms.m4
@ -1,147 +0,0 @@
|
||||
dnl some macros to test for xforms-related functionality -*- sh -*-
|
||||
|
||||
dnl Usage LYX_PATH_XPM: Checks for xpm library and header
|
||||
AC_DEFUN([LYX_PATH_XPM],[
|
||||
### Check for Xpm library
|
||||
AC_CHECK_LIB(Xpm, XpmCreateBufferFromImage, XPM_LIB="-lXpm",
|
||||
[LYX_LIB_ERROR(libXpm,Xpm)])
|
||||
### Check for Xpm headers
|
||||
lyx_cv_xpm_h_location="<xpm.h>"
|
||||
AC_CHECK_HEADER(X11/xpm.h,[
|
||||
ac_cv_header_xpm_h=yes
|
||||
lyx_cv_xpm_h_location="<X11/xpm.h>"],[
|
||||
AC_CHECK_HEADER(xpm.h,[],[
|
||||
LYX_LIB_ERROR(xpm.h,Xpm)])])
|
||||
AC_SUBST(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
|
||||
### Test for the header version
|
||||
if test $ac_cv_header_xpm_h = yes; then
|
||||
AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
|
||||
[ cat > conftest.$ac_ext <<EOF
|
||||
#line __oline__ "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include $lyx_cv_xpm_h_location
|
||||
"%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
|
||||
EOF
|
||||
eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
|
||||
grep '^"%%%"' 2>/dev/null | \
|
||||
sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
|
||||
case "$lyx_cv_xpmr" in
|
||||
changequote(,)
|
||||
[0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
|
||||
lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
|
||||
changequote([,])
|
||||
*) ;;
|
||||
esac
|
||||
lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
|
||||
rm -f conftest*])
|
||||
XPM_VERSION=${lyx_cv_xpmversion}
|
||||
case "$lyx_cv_xpmr" in
|
||||
changequote(,)
|
||||
[789]|[0-9][0-9]*) ;;
|
||||
changequote([,])
|
||||
*) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old.
|
||||
If you experience strange crashes with LyX, try to upgrade
|
||||
to at least version 4.7 (aka 3.4g).
|
||||
If you have installed a newer version of the library, check whether you
|
||||
have an old xpm.h header file in your include path.]);;
|
||||
esac
|
||||
fi])
|
||||
|
||||
|
||||
dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
|
||||
dnl If it is found, the variable XFORMS_LIB is set to the relevant -l flags,
|
||||
dnl and FORMS_H_LOCATION / FLIMAGE_H_LOCATION is also set
|
||||
AC_DEFUN([LYX_PATH_XFORMS],[
|
||||
AC_REQUIRE([LYX_PATH_XPM])
|
||||
|
||||
AC_CHECK_LIB(forms, fl_initialize, XFORMS_LIB="-lforms",
|
||||
[AC_CHECK_LIB(xforms, fl_initialize, XFORMS_LIB="-lxforms",
|
||||
[LYX_LIB_ERROR(libforms or libxforms,xforms)], $XPM_LIB)], $XPM_LIB)
|
||||
|
||||
### Check for xforms headers
|
||||
lyx_cv_forms_h_location="<forms.h>"
|
||||
AC_CHECK_HEADER(X11/forms.h,[
|
||||
ac_cv_header_forms_h=yes
|
||||
lyx_cv_forms_h_location="<X11/forms.h>"],[
|
||||
AC_CHECK_HEADER(forms.h,[],[
|
||||
LYX_LIB_ERROR(forms.h,forms)])])
|
||||
AC_SUBST(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
|
||||
|
||||
if test $ac_cv_header_forms_h = yes; then
|
||||
AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
|
||||
[ cat > conftest.$ac_ext <<EOF
|
||||
#line __oline__ "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include $lyx_cv_forms_h_location
|
||||
#if ! defined(FL_INCLUDE_VERSION)
|
||||
"%%%"(unknown)"%%%"
|
||||
#else
|
||||
"%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
|
||||
#endif
|
||||
EOF
|
||||
lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
|
||||
grep '^"%%%"' 2>/dev/null | \
|
||||
sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
|
||||
rm -f conftest*])
|
||||
|
||||
XFORMS_VERSION=$lyx_cv_xfversion
|
||||
case "$lyx_cv_xfversion" in
|
||||
"(unknown)"|0.8[[1-8]]*|0.89[[01234]])
|
||||
LYX_ERROR(dnl
|
||||
Version $lyx_cv_xfversion of xforms is not compatible with LyX.
|
||||
This version of LyX works best with version 1.0 (recommended) and later.) ;;
|
||||
0.89*|0.9999*)
|
||||
LYX_WARNING(dnl
|
||||
LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
|
||||
it contains many bugs that have been squashed in version 1.0.
|
||||
You should consider upgrading.) ;;
|
||||
1.0*) ;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl Check the details of the xforms image loader
|
||||
AC_DEFUN([LYX_CHECK_XFORMS_IMAGE_LOADER],
|
||||
[AC_REQUIRE([LYX_PATH_XFORMS])
|
||||
save_LIBS=$LIBS
|
||||
LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
|
||||
lyx_use_jpeg_image_loader=no
|
||||
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
|
||||
dnl The image headers were split out of forms.h in xforms version 1.0.
|
||||
AC_CHECK_HEADERS(flimage.h X11/flimage.h, break,,[#include $lyx_cv_forms_h_location])
|
||||
|
||||
dnl Only enable native loading of jpeg images if the jpeg library is installed.
|
||||
dnl This test comes before that of flimage itself to ensure that the necessary
|
||||
dnl libraries are linked into the "flimage_dup" test program below.
|
||||
XFORMS_IMAGE_LIB=""
|
||||
AC_CHECK_LIB(jpeg, jpeg_read_header,
|
||||
[lyx_use_jpeg_image_loader=yes
|
||||
XFORMS_IMAGE_LIB="-ljpeg"
|
||||
LIBS="-ljpeg $LIBS"])
|
||||
|
||||
AC_SEARCH_LIBS(flimage_dup, flimage,
|
||||
[if test "$ac_cv_search_flimage_dup" != "none required" ; then
|
||||
XFORMS_IMAGE_LIB="-lflimage $XFORMS_IMAGE_LIB"
|
||||
fi])
|
||||
|
||||
if test $lyx_use_jpeg_image_loader = yes ; then
|
||||
lyx_flags="$lyx_flags jpeg-image-loader"
|
||||
AC_DEFINE(USE_JPEG_IMAGE_LOADER, 1,
|
||||
[Define if you want to be able to load jpeg images natively])
|
||||
fi
|
||||
|
||||
AC_LANG_RESTORE
|
||||
LIBS=$save_LIBS])
|
||||
|
||||
dnl Do all check required to use xforms
|
||||
AC_DEFUN([XFORMS_DO_IT_ALL],
|
||||
[LYX_PATH_XPM
|
||||
LYX_PATH_XFORMS
|
||||
LYX_CHECK_XFORMS_IMAGE_LOADER
|
||||
AC_SUBST(XFORMS_LIBS, ["$XFORMS_IMAGE_LIB $XFORMS_LIB $XPM_LIB"])])
|
14
configure.ac
14
configure.ac
@ -167,16 +167,6 @@ dnl The code below is not in a macro, because this would cause big
|
||||
dnl problems with the AC_REQUIRE contained in QT_DO_IT_ALL.
|
||||
for frontend in $FRONTENDS ; do
|
||||
case "$frontend" in
|
||||
xforms)
|
||||
XFORMS_DO_IT_ALL
|
||||
FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-xforms\$(EXEEXT)"
|
||||
FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS xforms"
|
||||
RPM_FRONTEND="xforms"
|
||||
FRONTEND_INFO="${FRONTEND_INFO}\
|
||||
XForms Frontend:\n\
|
||||
libXpm version:\t\t${XPM_VERSION}\n\
|
||||
libforms version:\t\t${XFORMS_VERSION}\n"
|
||||
;;
|
||||
gtk)
|
||||
PKG_CHECK_MODULES(GTK_FRONTEND, gtkmm-2.4 libglademm-2.4 xft)
|
||||
FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-gtk\$(EXEEXT)"
|
||||
@ -443,10 +433,6 @@ AC_CONFIG_FILES([Makefile m4/Makefile \
|
||||
src/frontends/Makefile \
|
||||
src/frontends/controllers/Makefile \
|
||||
src/frontends/controllers/tests/Makefile \
|
||||
src/frontends/xforms/Makefile \
|
||||
src/frontends/xforms/lyx_forms.h-tmp:src/frontends/xforms/lyx_forms.h.in \
|
||||
src/frontends/xforms/lyx_xpm.h-tmp:src/frontends/xforms/lyx_xpm.h.in \
|
||||
src/frontends/xforms/forms/Makefile \
|
||||
src/frontends/gtk/Makefile \
|
||||
src/frontends/gtk/gimages/Makefile \
|
||||
src/frontends/gtk/glade/Makefile \
|
||||
|
@ -369,43 +369,14 @@ ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS)
|
||||
rm -f $@-t \
|
||||
&& ( cd $(top_srcdir); \
|
||||
grep -l "_(\".*\")" `find src \( -name '*.[Cch]' -o -name '*.C.in' \) -print` |\
|
||||
sed -e '/xforms.forms/d'| grep -v -e "src/support/package.C$$" |\
|
||||
grep -v -e "src/support/package.C$$" |\
|
||||
sort | uniq ) > $@-t \
|
||||
&& mv $@-t $@
|
||||
|
||||
l10n_pots: xforms_l10n.pot qt_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot
|
||||
l10n_pots: qt_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot
|
||||
cat $^ | \
|
||||
msguniq -o $(DOMAIN).po && rm -f $^
|
||||
|
||||
xforms_l10n.pot: $(top_srcdir)/src/frontends/xforms/forms/*.fd
|
||||
LC_ALL=C ; export LC_ALL ; \
|
||||
$(AWK) -v top_srcdir="$(top_srcdir)" ' \
|
||||
function fixupfilename() \
|
||||
{\
|
||||
return substr(FILENAME, length(top_srcdir "/") + 1);\
|
||||
}\
|
||||
BEGIN { \
|
||||
print "#, fuzzy"; \
|
||||
print "msgid \"\""; \
|
||||
print "msgstr \"\""; \
|
||||
print "\"Content-Type: text/plain; charset=ISO-8859-1\\n\""; \
|
||||
print "\"Content-Transfer-Encoding: 8bit\\n\""; \
|
||||
print "\n"; \
|
||||
skip=0; \
|
||||
} \
|
||||
/style: 15/ { \
|
||||
skip=1; \
|
||||
} \
|
||||
/label: / { \
|
||||
if (NF > 1 && skip == 0) { \
|
||||
line=$$0;\
|
||||
sub(/label: /,"",line);\
|
||||
printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", fixupfilename(), FNR, line);\
|
||||
}\
|
||||
skip=0; \
|
||||
}' \
|
||||
${top_srcdir}/src/frontends/xforms/forms/*.fd > $@
|
||||
|
||||
qt_l10n.pot: $(top_srcdir)/src/frontends/qt3/ui/*.ui
|
||||
LC_ALL=C ; export LC_ALL ; \
|
||||
$(AWK) -v top_srcdir="$(top_srcdir)" ' \
|
||||
|
@ -159,62 +159,12 @@ src/frontends/qt4/QTabular.C
|
||||
src/frontends/qt4/QTabularCreate.C
|
||||
src/frontends/qt4/QTexinfo.C
|
||||
src/frontends/qt4/QThesaurus.C
|
||||
src/frontends/qt4/UrlView.C
|
||||
src/frontends/qt4/QVSpace.C
|
||||
src/frontends/qt4/QWrap.C
|
||||
src/frontends/qt4/Qt2BC.h
|
||||
src/frontends/qt4/UrlView.C
|
||||
src/frontends/qt4/floatplacement.C
|
||||
src/frontends/qt4/validators.C
|
||||
src/frontends/xforms/Alert_pimpl.C
|
||||
src/frontends/xforms/ColorHandler.C
|
||||
src/frontends/xforms/Dialogs.C
|
||||
src/frontends/xforms/FormAboutlyx.C
|
||||
src/frontends/xforms/FormBibitem.C
|
||||
src/frontends/xforms/FormBibtex.C
|
||||
src/frontends/xforms/FormBox.C
|
||||
src/frontends/xforms/FormBranch.C
|
||||
src/frontends/xforms/FormChanges.C
|
||||
src/frontends/xforms/FormCharacter.C
|
||||
src/frontends/xforms/FormCitation.C
|
||||
src/frontends/xforms/FormColorpicker.C
|
||||
src/frontends/xforms/FormDialogView.C
|
||||
src/frontends/xforms/FormDocument.C
|
||||
src/frontends/xforms/FormERT.C
|
||||
src/frontends/xforms/FormErrorList.C
|
||||
src/frontends/xforms/FormExternal.C
|
||||
src/frontends/xforms/FormFiledialog.C
|
||||
src/frontends/xforms/FormFloat.C
|
||||
src/frontends/xforms/FormGraphics.C
|
||||
src/frontends/xforms/FormInclude.C
|
||||
src/frontends/xforms/FormMathsBitmap.C
|
||||
src/frontends/xforms/FormMathsDelim.C
|
||||
src/frontends/xforms/FormMathsMatrix.C
|
||||
src/frontends/xforms/FormMathsPanel.C
|
||||
src/frontends/xforms/FormMathsSpace.C
|
||||
src/frontends/xforms/FormMathsStyle.C
|
||||
src/frontends/xforms/FormNote.C
|
||||
src/frontends/xforms/FormParagraph.C
|
||||
src/frontends/xforms/FormPreamble.C
|
||||
src/frontends/xforms/FormPreferences.C
|
||||
src/frontends/xforms/FormPrint.C
|
||||
src/frontends/xforms/FormRef.C
|
||||
src/frontends/xforms/FormSearch.C
|
||||
src/frontends/xforms/FormSendto.C
|
||||
src/frontends/xforms/FormShowFile.C
|
||||
src/frontends/xforms/FormSpellchecker.C
|
||||
src/frontends/xforms/FormTabular.C
|
||||
src/frontends/xforms/FormTabularCreate.C
|
||||
src/frontends/xforms/FormTexinfo.C
|
||||
src/frontends/xforms/FormThesaurus.C
|
||||
src/frontends/xforms/FormToc.C
|
||||
src/frontends/xforms/FormUrl.C
|
||||
src/frontends/xforms/FormVSpace.C
|
||||
src/frontends/xforms/FormWrap.C
|
||||
src/frontends/xforms/XFormsMenubar.C
|
||||
src/frontends/xforms/XMiniBuffer.C
|
||||
src/frontends/xforms/checkedwidgets.C
|
||||
src/frontends/xforms/xformsBC.h
|
||||
src/frontends/xforms/xforms_helpers.C
|
||||
src/gettext.h
|
||||
src/importer.C
|
||||
src/insets/insetbase.C
|
||||
|
@ -31,12 +31,7 @@ OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $(AIKSAURUS_LIBS) @LIBS@ $(SOCKET_LIBS)
|
||||
|
||||
bin_PROGRAMS = lyx
|
||||
noinst_PROGRAMS = $(FRONTENDS_PROGS)
|
||||
EXTRA_PROGRAMS = lyx-xforms lyx-qt lyx-gtk lyx-qt4
|
||||
|
||||
lyx_xforms_LDADD = $(lyx_OBJECTS) $(LYX_PRE_LIBS) \
|
||||
frontends/xforms/libxforms.la $(LYX_POST_LIBS) $(OTHERLIBS)
|
||||
|
||||
lyx_xforms_SOURCES = main.C
|
||||
EXTRA_PROGRAMS = lyx-qt lyx-gtk lyx-qt4
|
||||
|
||||
lyx_qt_LDADD = $(lyx_OBJECTS) $(LYX_PRE_LIBS) \
|
||||
frontends/qt3/libqt3.la $(LYX_POST_LIBS) $(OTHERLIBS)
|
||||
|
@ -2,7 +2,7 @@ include $(top_srcdir)/config/common.am
|
||||
|
||||
SUBDIRS = controllers $(FRONTENDS_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = controllers xforms qt3 gtk qt4
|
||||
DIST_SUBDIRS = controllers qt3 gtk qt4
|
||||
|
||||
EXTRA_DIST = pch.h
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/**
|
||||
* \file xforms/Alert_pimpl.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Alert_pimpl.h"
|
||||
|
||||
#include "forms_gettext.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using lyx::frontend::formatted;
|
||||
using lyx::frontend::idex;
|
||||
using lyx::frontend::parse_shortcut;
|
||||
|
||||
using std::make_pair;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
|
||||
|
||||
void warning_pimpl(string const &, string const & message)
|
||||
{
|
||||
fl_show_messages(formatted(message, 300).c_str());
|
||||
}
|
||||
|
||||
|
||||
void error_pimpl(string const &, string const & message)
|
||||
{
|
||||
fl_show_messages(formatted(message, 300).c_str());
|
||||
}
|
||||
|
||||
|
||||
void information_pimpl(string const &, string const & message)
|
||||
{
|
||||
fl_show_messages(formatted(message, 300).c_str());
|
||||
}
|
||||
|
||||
|
||||
int prompt_pimpl(string const &, string const & question,
|
||||
int default_button, int /*escape_button*/,
|
||||
string const & b1, string const & b2, string const & b3)
|
||||
{
|
||||
string b1label, b1sc;
|
||||
string b2label, b2sc;
|
||||
string b3label, b3sc;
|
||||
boost::tie(b1label, b1sc) = parse_shortcut(b1);
|
||||
boost::tie(b2label, b2sc) = parse_shortcut(b2);
|
||||
boost::tie(b3label, b3sc) = parse_shortcut(b3);
|
||||
|
||||
if (b3.empty()) {
|
||||
fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
|
||||
return fl_show_choices(formatted(question, 300).c_str(),
|
||||
2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
|
||||
} else {
|
||||
fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
|
||||
return fl_show_choices(formatted(question, 300).c_str(),
|
||||
3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
|
||||
default_button + 1) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
|
||||
{
|
||||
fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
|
||||
fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
|
||||
fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
|
||||
char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
|
||||
if (tmp != 0)
|
||||
return make_pair<bool, string>(true, string(tmp));
|
||||
else
|
||||
return make_pair<bool, string>(false, string());
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,277 +0,0 @@
|
||||
/**
|
||||
* \file ColorHandler.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ColorHandler.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "LColor.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::pow;
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace support {
|
||||
namespace {
|
||||
|
||||
string tostr(XColor const & col)
|
||||
{
|
||||
return bformat("(%1$s,%2$s,%3$s)",
|
||||
::convert<string>(col.red),
|
||||
::convert<string>(col.green),
|
||||
::convert<string>(col.blue));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace support
|
||||
|
||||
using support::bformat;
|
||||
using support::tostr;
|
||||
|
||||
|
||||
namespace frontend {
|
||||
|
||||
LyXColorHandler::LyXColorHandler()
|
||||
: colorGCcache(LColor::ignore + 1)
|
||||
{
|
||||
display = fl_get_display();
|
||||
drawable = XCreatePixmap(display,
|
||||
RootWindow(display, fl_screen),
|
||||
10, 10, fl_get_visual_depth());
|
||||
|
||||
colormap = fl_state[fl_get_vclass()].colormap;
|
||||
// Clear the GC cache
|
||||
for (string::size_type i = 0; i < colorGCcache.size(); ++i) {
|
||||
colorGCcache[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LyXColorHandler::~LyXColorHandler()
|
||||
{
|
||||
// Release all the registered GCs
|
||||
for (unsigned i = 0; i < colorGCcache.size(); ++i) {
|
||||
if (colorGCcache[i] != 0) {
|
||||
XFreeGC(display, colorGCcache[i]);
|
||||
}
|
||||
}
|
||||
// Iterate over the line cache and Free the GCs
|
||||
for (LineGCCache::iterator lit = lineGCcache.begin();
|
||||
lit != lineGCcache.end(); ++lit) {
|
||||
XFreeGC(display, lit->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long LyXColorHandler::colorPixel(LColor_color c)
|
||||
{
|
||||
XGCValues val;
|
||||
XGetGCValues(display, getGCForeground(c), GCForeground, &val);
|
||||
return val.foreground;
|
||||
}
|
||||
|
||||
|
||||
GC LyXColorHandler::getGCForeground(string const & s)
|
||||
{
|
||||
XColor xcol;
|
||||
XColor ccol;
|
||||
XGCValues val;
|
||||
// Look up the RGB values for the color, and an approximate
|
||||
// color that we can hope to get on this display.
|
||||
if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
|
||||
lyxerr << bformat(
|
||||
_("LyX: Unknown X11 color %1$s\n"
|
||||
" Using black instead, sorry!"),
|
||||
s) << endl;
|
||||
unsigned long bla = BlackPixel(display,
|
||||
DefaultScreen(display));
|
||||
val.foreground = bla;
|
||||
// Try the exact RGB values first, then the approximate.
|
||||
} else if (XAllocColor(display, colormap, &xcol) != 0) {
|
||||
if (lyxerr.debugging(Debug::GUI)) {
|
||||
lyxerr << bformat(_("LyX: X11 color %1$s allocated"),
|
||||
s) << endl;
|
||||
}
|
||||
val.foreground = xcol.pixel;
|
||||
} else {
|
||||
// Here we are traversing the current colormap to find
|
||||
// the color closest to the one we want.
|
||||
Visual * vi = DefaultVisual(display, DefaultScreen(display));
|
||||
|
||||
boost::scoped_array<XColor> cmap(new XColor[vi->map_entries]);
|
||||
|
||||
for (int i = 0; i < vi->map_entries; ++i) {
|
||||
cmap[i].pixel = i;
|
||||
}
|
||||
XQueryColors(display, colormap, cmap.get(), vi->map_entries);
|
||||
|
||||
// Walk through the cmap and look for close colors.
|
||||
int closest_pixel = 0;
|
||||
double closest_distance = 1e20; // we want to minimize this
|
||||
double distance = 0;
|
||||
for (int t = 0; t < vi->map_entries; ++t) {
|
||||
// The Euclidean distance between two points in
|
||||
// a three-dimensional space, the RGB color-cube,
|
||||
// is used as the distance measurement between two
|
||||
// colors.
|
||||
|
||||
// Since square-root is monotonous, we don't have to
|
||||
// take the square-root to find the minimum, and thus
|
||||
// we use the squared distance instead to be faster.
|
||||
|
||||
// If we want to get fancy, we could convert the RGB
|
||||
// coordinates to a different color-cube, maybe HSV,
|
||||
// but the RGB cube seems to work great. (Asger)
|
||||
distance = pow(cmap[t].red - xcol.red, 2.0) +
|
||||
pow(cmap[t].green - xcol.green, 2.0) +
|
||||
pow(cmap[t].blue - xcol.blue, 2.0);
|
||||
if (distance < closest_distance) {
|
||||
closest_distance = distance;
|
||||
closest_pixel = t;
|
||||
}
|
||||
}
|
||||
|
||||
lyxerr << bformat(
|
||||
_("LyX: Couldn't allocate '%1$s' with (r,g,b)=%2$s.\n"),
|
||||
s, tostr(xcol));
|
||||
|
||||
lyxerr << bformat(
|
||||
_(" Using closest allocated color with (r,g,b)=%1$s instead.\n"
|
||||
"Pixel [%2$s] is used."),
|
||||
tostr(cmap[closest_pixel]), convert<string>(closest_pixel)) << endl;
|
||||
|
||||
val.foreground = cmap[closest_pixel].pixel;
|
||||
}
|
||||
val.function = GXcopy;
|
||||
return XCreateGC(display, drawable,
|
||||
GCForeground | GCFunction, &val);
|
||||
}
|
||||
|
||||
// Gets GC according to color
|
||||
// Uses caching
|
||||
GC LyXColorHandler::getGCForeground(LColor_color c)
|
||||
{
|
||||
if (static_cast<unsigned>(c) >= colorGCcache.size()) {
|
||||
colorGCcache.resize(c + 1, 0);
|
||||
}
|
||||
|
||||
if (colorGCcache[c] != 0) {
|
||||
return colorGCcache[c];
|
||||
}
|
||||
XColor xcol;
|
||||
XColor ccol;
|
||||
string const s = lcolor.getX11Name(c);
|
||||
// Look up the RGB values for the color, and an approximate
|
||||
// color that we can hope to get on this display.
|
||||
if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
|
||||
lyxerr << bformat(
|
||||
_("LyX: Unknown X11 color %1$s for %2$s\n"),
|
||||
s, lcolor.getGUIName(c)) << endl;
|
||||
}
|
||||
return colorGCcache[c] = getGCForeground(s);
|
||||
}
|
||||
|
||||
|
||||
// Gets GC for line
|
||||
GC LyXColorHandler::getGCLinepars(Painter::line_style ls,
|
||||
Painter::line_width lw, LColor_color c)
|
||||
{
|
||||
//if (lyxerr.debugging()) {
|
||||
// lyxerr << "Painter drawable: " << drawable() << endl;
|
||||
//}
|
||||
|
||||
int index = lw + (ls << 1) + (c << 6);
|
||||
|
||||
LineGCCache::iterator it = lineGCcache.find(index);
|
||||
if (it != lineGCcache.end())
|
||||
return it->second;
|
||||
|
||||
XGCValues val;
|
||||
XGetGCValues(display, getGCForeground(c), GCForeground, &val);
|
||||
|
||||
switch (lw) {
|
||||
case Painter::line_thin:
|
||||
val.line_width = 0;
|
||||
break;
|
||||
case Painter::line_thick:
|
||||
val.line_width = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ls) {
|
||||
case Painter::line_solid:
|
||||
val.line_style = LineSolid;
|
||||
break;
|
||||
case Painter::line_onoffdash:
|
||||
val.line_style = LineOnOffDash;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
val.cap_style = CapRound;
|
||||
val.join_style = JoinRound;
|
||||
val.function = GXcopy;
|
||||
|
||||
return lineGCcache[index] =
|
||||
XCreateGC(display, drawable,
|
||||
GCForeground | GCLineStyle | GCLineWidth |
|
||||
GCCapStyle | GCJoinStyle | GCFunction, &val);
|
||||
}
|
||||
|
||||
|
||||
// update GC cache after color redefinition
|
||||
void LyXColorHandler::updateColor (LColor_color c)
|
||||
{
|
||||
// color GC cache
|
||||
GC gc = colorGCcache[c];
|
||||
if (gc != 0) {
|
||||
XFreeGC(display, gc);
|
||||
colorGCcache[c] = NULL;
|
||||
getGCForeground(c);
|
||||
}
|
||||
|
||||
// line GC cache
|
||||
|
||||
for (int ls = 0; ls < 3; ++ls)
|
||||
for (int lw = 0; lw < 2; ++lw) {
|
||||
int const index = lw + (ls << 1) + (c << 6);
|
||||
LineGCCache::iterator it = lineGCcache.find(index);
|
||||
if (it != lineGCcache.end()) {
|
||||
gc = it->second;
|
||||
XFreeGC(display, gc);
|
||||
lineGCcache.erase(it);
|
||||
getGCLinepars(Painter::line_style(ls),
|
||||
Painter::line_width(lw), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,73 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ColorHandler.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef COLOR_HANDLER_H
|
||||
#define COLOR_HANDLER_H
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
// This is only included to provide stuff for the non-public sections
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
class LColor_color;
|
||||
class LyXFont;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* This is a factory class that can produce GCs with a specific
|
||||
* color. It will cache GCs for performance.
|
||||
*/
|
||||
class LyXColorHandler {
|
||||
public:
|
||||
///
|
||||
LyXColorHandler();
|
||||
///
|
||||
~LyXColorHandler();
|
||||
///
|
||||
unsigned long colorPixel(LColor_color c);
|
||||
///
|
||||
GC getGCForeground(LColor_color c);
|
||||
///
|
||||
GC getGCLinepars(Painter::line_style,
|
||||
Painter::line_width, LColor_color c);
|
||||
/// update the cache after a color definition change
|
||||
void updateColor(LColor_color c);
|
||||
|
||||
private:
|
||||
///
|
||||
Display * display;
|
||||
///
|
||||
Colormap colormap;
|
||||
///
|
||||
std::vector<GC> colorGCcache;
|
||||
///
|
||||
GC getGCForeground(std::string const & s);
|
||||
///
|
||||
typedef std::map<int, GC> LineGCCache;
|
||||
///
|
||||
LineGCCache lineGCcache;
|
||||
///
|
||||
Pixmap drawable;
|
||||
};
|
||||
|
||||
///
|
||||
extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,521 +0,0 @@
|
||||
/**
|
||||
* \file xforms/Dialogs.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Dialogs.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
|
||||
#include "ControlAboutlyx.h"
|
||||
#include "ControlBibtex.h"
|
||||
#include "ControlBox.h"
|
||||
#include "ControlBranch.h"
|
||||
#include "ControlChanges.h"
|
||||
#include "ControlCitation.h"
|
||||
#include "ControlDocument.h"
|
||||
#include "ControlErrorList.h"
|
||||
#include "ControlERT.h"
|
||||
#include "ControlExternal.h"
|
||||
#include "ControlFloat.h"
|
||||
#include "ControlGraphics.h"
|
||||
#include "ControlInclude.h"
|
||||
#include "ControlLog.h"
|
||||
#include "ControlMath.h"
|
||||
#include "ControlNote.h"
|
||||
#include "ControlParagraph.h"
|
||||
#include "ControlPreamble.h"
|
||||
#include "ControlPrefs.h"
|
||||
#include "ControlPrint.h"
|
||||
#include "ControlRef.h"
|
||||
#include "ControlSearch.h"
|
||||
#include "ControlSendto.h"
|
||||
#include "ControlShowFile.h"
|
||||
#include "ControlSpellchecker.h"
|
||||
#include "ControlTabular.h"
|
||||
#include "ControlTabularCreate.h"
|
||||
#include "ControlToc.h"
|
||||
#include "ControlVSpace.h"
|
||||
#include "ControlWrap.h"
|
||||
|
||||
#include "FormAboutlyx.h"
|
||||
#include "FormBibitem.h"
|
||||
#include "FormBibtex.h"
|
||||
#include "FormBox.h"
|
||||
#include "FormBranch.h"
|
||||
#include "FormChanges.h"
|
||||
#include "FormCharacter.h"
|
||||
#include "FormCitation.h"
|
||||
#include "FormDocument.h"
|
||||
#include "FormErrorList.h"
|
||||
#include "FormERT.h"
|
||||
#include "FormExternal.h"
|
||||
#include "FormFloat.h"
|
||||
#include "FormGraphics.h"
|
||||
#include "FormInclude.h"
|
||||
#include "FormLog.h"
|
||||
#include "FormMathsPanel.h"
|
||||
#include "FormMathsBitmap.h"
|
||||
#include "FormMathsDelim.h"
|
||||
#include "FormMathsMatrix.h"
|
||||
#include "FormMathsSpace.h"
|
||||
#include "FormMathsStyle.h"
|
||||
#include "FormNote.h"
|
||||
#include "FormParagraph.h"
|
||||
#include "FormPreamble.h"
|
||||
#include "FormPreferences.h"
|
||||
#include "FormPrint.h"
|
||||
#include "FormRef.h"
|
||||
#include "FormTabular.h"
|
||||
#include "FormTexinfo.h"
|
||||
#include "FormSearch.h"
|
||||
#include "FormSendto.h"
|
||||
#include "FormShowFile.h"
|
||||
#include "FormSpellchecker.h"
|
||||
#include "FormTabularCreate.h"
|
||||
#include "FormText.h"
|
||||
#include "FormToc.h"
|
||||
#include "FormUrl.h"
|
||||
#include "FormVSpace.h"
|
||||
#include "FormWrap.h"
|
||||
|
||||
#ifdef HAVE_LIBAIKSAURUS
|
||||
#include "ControlThesaurus.h"
|
||||
#include "FormThesaurus.h"
|
||||
#endif
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "ButtonController.h"
|
||||
|
||||
#include "arrows.xbm"
|
||||
#include "bop.xbm"
|
||||
#include "brel.xbm"
|
||||
#include "deco.xbm"
|
||||
#include "dots.xbm"
|
||||
#include "greek.xbm"
|
||||
#include "misc.xbm"
|
||||
#include "varsz.xbm"
|
||||
|
||||
#include "ams_misc.xbm"
|
||||
#include "ams_arrows.xbm"
|
||||
#include "ams_rel.xbm"
|
||||
#include "ams_nrel.xbm"
|
||||
#include "ams_ops.xbm"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
|
||||
using std::string;
|
||||
using namespace lyx::frontend;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
|
||||
char const * const * data, int size)
|
||||
{
|
||||
char const * const * const end = data + size;
|
||||
return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
|
||||
}
|
||||
|
||||
|
||||
char const * const dialognames[] = {
|
||||
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
|
||||
"citation", "document", "errorlist" , "ert", "external", "file",
|
||||
"findreplace", "float", "graphics", "include", "index", "label", "log",
|
||||
"mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations",
|
||||
"mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
|
||||
"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
|
||||
"mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
|
||||
"note", "paragraph", "preamble", "prefs", "print", "ref", "sendto",
|
||||
"spellchecker", "tabular", "tabularcreate", "texinfo",
|
||||
|
||||
#ifdef HAVE_LIBAIKSAURUS
|
||||
"thesaurus",
|
||||
#endif
|
||||
|
||||
"toc", "url", "vspace", "wrap" };
|
||||
|
||||
char const * const * const end_dialognames =
|
||||
dialognames + (sizeof(dialognames) / sizeof(char *));
|
||||
|
||||
struct cmpCStr {
|
||||
cmpCStr(char const * name) : name_(name) {}
|
||||
bool operator()(char const * other) {
|
||||
return strcmp(other, name_) == 0;
|
||||
}
|
||||
private:
|
||||
char const * name_;
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
bool Dialogs::isValidName(string const & name) const
|
||||
{
|
||||
return std::find_if(dialognames, end_dialognames,
|
||||
cmpCStr(name.c_str())) != end_dialognames;
|
||||
}
|
||||
|
||||
|
||||
Dialogs::DialogPtr Dialogs::build(string const & name)
|
||||
{
|
||||
BOOST_ASSERT(isValidName(name));
|
||||
|
||||
DialogPtr dialog(new Dialog(lyxview_, name));
|
||||
dialog->bc().view(new xformsBC(dialog->bc()));
|
||||
|
||||
if (name == "aboutlyx") {
|
||||
dialog->setController(new ControlAboutlyx(*dialog));
|
||||
dialog->setView(new FormAboutlyx(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
} else if (name == "bibitem") {
|
||||
dialog->setController(new ControlCommand(*dialog, name));
|
||||
dialog->setView(new FormBibitem(*dialog));
|
||||
dialog->bc().bp(new OkCancelReadOnlyPolicy);
|
||||
} else if (name == "bibtex") {
|
||||
dialog->setController(new ControlBibtex(*dialog));
|
||||
dialog->setView(new FormBibtex(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "box") {
|
||||
dialog->setController(new ControlBox(*dialog));
|
||||
dialog->setView(new FormBox(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "branch") {
|
||||
dialog->setController(new ControlBranch(*dialog));
|
||||
dialog->setView(new FormBranch(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "changes") {
|
||||
dialog->setController(new ControlChanges(*dialog));
|
||||
dialog->setView(new FormChanges(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "character") {
|
||||
dialog->setController(new ControlCharacter(*dialog));
|
||||
dialog->setView(new FormCharacter(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "citation") {
|
||||
dialog->setController(new ControlCitation(*dialog));
|
||||
dialog->setView(new FormCitation(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "document") {
|
||||
dialog->setController(new ControlDocument(*dialog));
|
||||
dialog->setView(new FormDocument(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "errorlist") {
|
||||
dialog->setController(new ControlErrorList(*dialog));
|
||||
dialog->setView(new FormErrorList(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "ert") {
|
||||
dialog->setController(new ControlERT(*dialog));
|
||||
dialog->setView(new FormERT(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "external") {
|
||||
dialog->setController(new ControlExternal(*dialog));
|
||||
dialog->setView(new FormExternal(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "file") {
|
||||
dialog->setController(new ControlShowFile(*dialog));
|
||||
dialog->setView(new FormShowFile(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
} else if (name == "findreplace") {
|
||||
dialog->setController(new ControlSearch(*dialog));
|
||||
dialog->setView(new FormSearch(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "float") {
|
||||
dialog->setController(new ControlFloat(*dialog));
|
||||
dialog->setView(new FormFloat(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "graphics") {
|
||||
dialog->setController(new ControlGraphics(*dialog));
|
||||
dialog->setView(new FormGraphics(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "include") {
|
||||
dialog->setController(new ControlInclude(*dialog));
|
||||
dialog->setView(new FormInclude(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "index") {
|
||||
dialog->setController(new ControlCommand(*dialog, name));
|
||||
dialog->setView(new FormText(*dialog,
|
||||
_("Index Entry"), _("Keyword:|#K")));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "label") {
|
||||
dialog->setController(new ControlCommand(*dialog, name));
|
||||
dialog->setView(new FormText(*dialog,
|
||||
_("Label"), _("Label:|#L")));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "log") {
|
||||
dialog->setController(new ControlLog(*dialog));
|
||||
dialog->setView(new FormLog(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
|
||||
} else if (name == "mathpanel") {
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(new FormMathsPanel(*dialog));
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathaccents") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Maths Decorations & Accents"),
|
||||
latex_deco, nr_latex_deco);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "matharrows") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathoperators") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Binary Ops"),
|
||||
latex_bop, nr_latex_bop);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathrelations") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Binary Relations"),
|
||||
latex_brel, nr_latex_brel);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathgreek") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Greek"),
|
||||
latex_greek, nr_latex_greek);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathmisc") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Misc"),
|
||||
latex_misc, nr_latex_misc);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathdots") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Dots"),
|
||||
latex_dots, nr_latex_dots);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathbigoperators") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("Big Operators"),
|
||||
latex_varsz, nr_latex_varsz);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathamsmisc") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("AMS Misc"),
|
||||
latex_ams_misc, nr_latex_ams_misc);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathamsarrows") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("AMS Arrows"),
|
||||
latex_ams_arrows, nr_latex_ams_arrows);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathamsrelations") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("AMS Relations"),
|
||||
latex_ams_rel, nr_latex_ams_rel);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathamsnegatedrelations") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("AMS Negated Rel"),
|
||||
latex_ams_nrel, nr_latex_ams_nrel);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathamsoperators") {
|
||||
FormMathsBitmap * bitmap =
|
||||
createFormBitmap(*dialog, _("AMS Operators"),
|
||||
latex_ams_ops, nr_latex_ams_ops);
|
||||
bitmap->addBitmap(
|
||||
BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
|
||||
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(bitmap);
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
|
||||
} else if (name == "mathdelimiter") {
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(new FormMathsDelim(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "mathmatrix") {
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(new FormMathsMatrix(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "mathspace") {
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(new FormMathsSpace(*dialog));
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
} else if (name == "mathstyle") {
|
||||
dialog->setController(new ControlMath(*dialog));
|
||||
dialog->setView(new FormMathsStyle(*dialog));
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
} else if (name == "note") {
|
||||
dialog->setController(new ControlNote(*dialog));
|
||||
dialog->setView(new FormNote(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "paragraph") {
|
||||
dialog->setController(new ControlParagraph(*dialog));
|
||||
dialog->setView(new FormParagraph(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "preamble") {
|
||||
dialog->setController(new ControlPreamble(*dialog));
|
||||
dialog->setView(new FormPreamble(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "prefs") {
|
||||
dialog->setController(new ControlPrefs(*dialog));
|
||||
dialog->setView(new FormPreferences(*dialog));
|
||||
dialog->bc().bp(new PreferencesPolicy);
|
||||
} else if (name == "print") {
|
||||
dialog->setController(new ControlPrint(*dialog));
|
||||
dialog->setView(new FormPrint(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelPolicy);
|
||||
} else if (name == "ref") {
|
||||
dialog->setController(new ControlRef(*dialog));
|
||||
dialog->setView(new FormRef(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "sendto") {
|
||||
dialog->setController(new ControlSendto(*dialog));
|
||||
dialog->setView(new FormSendto(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelPolicy);
|
||||
} else if (name == "spellchecker") {
|
||||
dialog->setController(new ControlSpellchecker(*dialog));
|
||||
dialog->setView(new FormSpellchecker(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "tabular") {
|
||||
dialog->setController(new ControlTabular(*dialog));
|
||||
dialog->setView(new FormTabular(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "tabularcreate") {
|
||||
dialog->setController(new ControlTabularCreate(*dialog));
|
||||
dialog->setView(new FormTabularCreate(*dialog));
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
} else if (name == "texinfo") {
|
||||
dialog->setController(new ControlTexinfo(*dialog));
|
||||
dialog->setView(new FormTexinfo(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
#ifdef HAVE_LIBAIKSAURUS
|
||||
} else if (name == "thesaurus") {
|
||||
dialog->setController(new ControlThesaurus(*dialog));
|
||||
dialog->setView(new FormThesaurus(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
#endif
|
||||
} else if (name == "toc") {
|
||||
dialog->setController(new ControlToc(*dialog));
|
||||
dialog->setView(new FormToc(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
} else if (name == "url") {
|
||||
dialog->setController(new ControlCommand(*dialog, name));
|
||||
dialog->setView(new FormUrl(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
} else if (name == "vspace") {
|
||||
dialog->setController(new ControlVSpace(*dialog));
|
||||
dialog->setView(new FormVSpace(*dialog));
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
} else if (name == "wrap") {
|
||||
dialog->setController(new ControlWrap(*dialog));
|
||||
dialog->setView(new FormWrap(*dialog));
|
||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
void Dialogs::toggleTooltips()
|
||||
{
|
||||
Tooltips::toggleEnabled();
|
||||
}
|
||||
|
||||
|
||||
/// Are the tooltips on or off?
|
||||
bool Dialogs::tooltipsEnabled()
|
||||
{
|
||||
return Tooltips::enabled();
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/**
|
||||
* \file xforms/FileDialog.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "frontends/FileDialog.h"
|
||||
#include "FormFiledialog.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "support/filefilterlist.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using lyx::support::rsplit;
|
||||
using lyx::support::FileFilterList;
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
|
||||
FileDialog::FileDialog(string const &t, kb_action s, Button b1, Button b2)
|
||||
: private_(0), title_(t), success_(s)
|
||||
{
|
||||
private_ = new FileDialog::Private;
|
||||
|
||||
private_->SetButton(0, b1.first, b1.second);
|
||||
private_->SetButton(1, b2.first, b2.second);
|
||||
}
|
||||
|
||||
|
||||
FileDialog::~FileDialog()
|
||||
{
|
||||
delete private_;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::save(string const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
{
|
||||
return open(path, filters, suggested);
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::opendir(string const & path, string const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "filedialog open with path \"" << path << "\", suggested \""
|
||||
<< suggested << '"' << endl;
|
||||
|
||||
// no support for asynchronous selection yet
|
||||
|
||||
FileDialog::Result result;
|
||||
|
||||
result.first = FileDialog::Chosen;
|
||||
result.second = private_->SelectDir(title_, path, suggested);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(string const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "filedialog open with path \"" << path
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
|
||||
// no support for asynchronous selection yet
|
||||
|
||||
FileDialog::Result result;
|
||||
|
||||
result.first = FileDialog::Chosen;
|
||||
result.second = private_->Select(title_, path, filters, suggested);
|
||||
|
||||
return result;
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
/**
|
||||
* \file FontInfo.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Asger Alstrup
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FontInfo.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "lyxrc.h" // lyxrc.use_scalable_fonts
|
||||
|
||||
#include "frontends/lyx_gui.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using std::abs;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::token;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
/// Load font close to this size
|
||||
string const FontInfo::getFontname(int size)
|
||||
{
|
||||
if (!exist())
|
||||
return string();
|
||||
|
||||
int closestind = -1;
|
||||
double error = 100000.0;
|
||||
|
||||
for (int i = 0; i < matches; ++i) {
|
||||
if (sizes[i] == 0) {
|
||||
// Scalable font should not be considered close
|
||||
} else if (sizes[i] == size) {
|
||||
lyxerr[Debug::FONT] << "Exact font match with\n"
|
||||
<< strings[i] << endl;
|
||||
return strings[i];
|
||||
} else if (abs(sizes[i] - size - 0.1) < error) {
|
||||
error = abs(sizes[i] - size - 0.1);
|
||||
closestind = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (scalable && (lyxrc.use_scalable_fonts || closestind == -1)) {
|
||||
// We can use scalable
|
||||
string const font = resize(strings[scaleindex], size);
|
||||
lyxerr[Debug::FONT] << "Using scalable font to get\n"
|
||||
<< font << endl;
|
||||
return font;
|
||||
}
|
||||
|
||||
// Did any fonts get close?
|
||||
if (closestind == -1) {
|
||||
// No, so...
|
||||
return string();
|
||||
}
|
||||
|
||||
// We use the closest match
|
||||
lyxerr[Debug::FONT] << "Using closest font match to get size "
|
||||
<< size
|
||||
<< " with\n" << strings[closestind] << endl;
|
||||
return strings[closestind];
|
||||
}
|
||||
|
||||
|
||||
/// Build newly sized font string
|
||||
string const FontInfo::resize(string const & font, int size) const
|
||||
{
|
||||
string ret(font);
|
||||
// Find the position of the size spec
|
||||
int cut = 0;
|
||||
string::iterator before = string::iterator(0);
|
||||
string::iterator after = string::iterator(0);
|
||||
for (string::iterator sit = ret.begin();
|
||||
sit != ret.end(); ++sit)
|
||||
if ((*sit) == '-') {
|
||||
++cut;
|
||||
if (cut == 7) before = sit + 1;
|
||||
else if (cut == 8) {
|
||||
after = sit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret.replace(before, after, convert<string>(size));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/// Set new pattern
|
||||
void FontInfo::setPattern(string const & pat)
|
||||
{
|
||||
init();
|
||||
pattern = pat;
|
||||
}
|
||||
|
||||
|
||||
/// Query font in X11
|
||||
void FontInfo::query()
|
||||
{
|
||||
if (queried)
|
||||
return;
|
||||
|
||||
queried = true;
|
||||
|
||||
if (pattern.empty()) {
|
||||
lyxerr << "Cannot use empty font name for font query."
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
char ** list = 0;
|
||||
if (lyx_gui::use_gui)
|
||||
list = XListFonts(fl_get_display(), pattern.c_str(),
|
||||
100, &matches);
|
||||
|
||||
if (list == 0) {
|
||||
// No fonts matched
|
||||
scalable = false;
|
||||
sizes.reset();
|
||||
} else {
|
||||
sizes.reset(new int[matches]);
|
||||
strings.reset(new string[matches]);
|
||||
|
||||
// We have matches. Run them through
|
||||
for (int i = 0; i < matches; ++i) {
|
||||
string name(list[i]);
|
||||
lyxerr[Debug::FONT] << "match #" << i << ' '
|
||||
<< name << endl;
|
||||
sizes[i] = convert<int>(token(name, '-', 7));
|
||||
strings[i] = name;
|
||||
if (sizes[i] == 0) {
|
||||
if (scaleindex == -1) {
|
||||
scaleindex = i;
|
||||
}
|
||||
scalable = true;
|
||||
} else if (convert<int>(token(name, '-', 12)) == 0)
|
||||
// Ignore bogus matches of scalable fonts.
|
||||
sizes[i] = 0;
|
||||
};
|
||||
XFreeFontNames(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FontInfo::init()
|
||||
{
|
||||
sizes.reset();
|
||||
strings.reset();
|
||||
matches = 0;
|
||||
queried = false;
|
||||
scalable = false;
|
||||
scaleindex = -1;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,96 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FontInfo.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Asger Alstrup
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FONTINFO_H
|
||||
#define FONTINFO_H
|
||||
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/** This class manages a font.
|
||||
The idea is to create a FontInfo object with a font name pattern with a
|
||||
wildcard at the size field. Then this object can host request for font-
|
||||
instances of any given size. If no exact match is found, the closest size
|
||||
is chosen instead. If the font is scalable, the flag
|
||||
lyxrc.use_scalable_fonts determines whether to allow scalable fonts to
|
||||
give an exact match.
|
||||
*/
|
||||
class FontInfo {
|
||||
public:
|
||||
///
|
||||
FontInfo() { init(); }
|
||||
|
||||
///
|
||||
explicit FontInfo(std::string const & pat)
|
||||
: pattern(pat) { init(); }
|
||||
|
||||
/// Does any font match our pattern?
|
||||
bool exist() {
|
||||
query();
|
||||
return matches != 0;
|
||||
}
|
||||
|
||||
/// Is this font scalable?
|
||||
bool isScalable() {
|
||||
query();
|
||||
return scalable;
|
||||
}
|
||||
|
||||
/// Get existing pattern
|
||||
std::string const & getPattern() const { return pattern; }
|
||||
|
||||
/// Set new pattern
|
||||
void setPattern(std::string const & pat);
|
||||
|
||||
/** Return full name of font close to this size.
|
||||
If impossible, result is the empty string */
|
||||
std::string const getFontname(int size);
|
||||
private:
|
||||
/// Font pattern (with wildcard for size)
|
||||
std::string pattern;
|
||||
|
||||
/// Available size list
|
||||
boost::scoped_array<int> sizes;
|
||||
|
||||
/// Corresponding name list
|
||||
boost::scoped_array<std::string> strings;
|
||||
|
||||
/// Number of matches
|
||||
int matches;
|
||||
|
||||
/// Did we query X about this font?
|
||||
bool queried;
|
||||
|
||||
/// Is this font scalable?
|
||||
bool scalable;
|
||||
|
||||
/// Which index points to scalable font entry?
|
||||
int scaleindex;
|
||||
|
||||
/// Initialize empty record
|
||||
void init();
|
||||
|
||||
/// Ask X11 about this font pattern
|
||||
void query();
|
||||
|
||||
/// Build newly sized font string
|
||||
std::string const resize(std::string const &, int size) const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FONTINFO_H
|
@ -1,101 +0,0 @@
|
||||
/**
|
||||
* \file FormAboutlyx.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
* \author Angus Leeming
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormAboutlyx.h"
|
||||
#include "xformsBC.h"
|
||||
#include "ControlAboutlyx.h"
|
||||
#include "forms/form_aboutlyx.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
|
||||
bool const scalableTabfolders = false;
|
||||
#else
|
||||
bool const scalableTabfolders = true;
|
||||
#endif
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlAboutlyx, FormView<FD_aboutlyx> > base_class;
|
||||
|
||||
FormAboutlyx::FormAboutlyx(Dialog & parent)
|
||||
: base_class(parent, _("About LyX"), scalableTabfolders)
|
||||
{}
|
||||
|
||||
|
||||
void FormAboutlyx::build()
|
||||
{
|
||||
dialog_.reset(build_aboutlyx(this));
|
||||
|
||||
// create version tab
|
||||
version_.reset(build_aboutlyx_version(this));
|
||||
|
||||
ostringstream vs;
|
||||
vs << controller().getVersion()
|
||||
<< '\n' << lyx_version_info;
|
||||
|
||||
fl_add_browser_line(version_->browser_version, vs.str().c_str());
|
||||
|
||||
// create credits tab
|
||||
credits_.reset(build_aboutlyx_credits(this));
|
||||
|
||||
ostringstream crs;
|
||||
controller().getCredits(crs);
|
||||
|
||||
std::string const credits_text =
|
||||
formatted(crs.str().c_str(),
|
||||
credits_->browser_credits->w - 15);
|
||||
fl_add_browser_line(credits_->browser_credits, credits_text.c_str());
|
||||
|
||||
// create license tab
|
||||
license_.reset(build_aboutlyx_license(this));
|
||||
int const width = license_->browser_license->w - 10;
|
||||
|
||||
ostringstream cs;
|
||||
cs << controller().getCopyright() << "\n\n"
|
||||
<< formatted(controller().getLicense(), width) << "\n\n"
|
||||
<< formatted(controller().getDisclaimer(), width);
|
||||
|
||||
fl_add_browser_line(license_->browser_license, cs.str().c_str());
|
||||
|
||||
// Enable the tabfolder to be rescaled correctly.
|
||||
if (scalableTabfolders)
|
||||
fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
|
||||
|
||||
// Stack tabs
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Version").c_str(),
|
||||
version_->form);
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Credits").c_str(),
|
||||
credits_->form);
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("License").c_str(),
|
||||
license_->form);
|
||||
|
||||
// Manage the cancel/close button
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,54 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormAboutlyx.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMABOUTLYX_H
|
||||
#define FORMABOUTLYX_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlAboutlyx;
|
||||
struct FD_aboutlyx;
|
||||
struct FD_aboutlyx_version;
|
||||
struct FD_aboutlyx_credits;
|
||||
struct FD_aboutlyx_license;
|
||||
|
||||
/** This class provides an XForms implementation of the FormAboutlyx Dialog.
|
||||
*/
|
||||
class FormAboutlyx
|
||||
: public FormController<ControlAboutlyx, FormView<FD_aboutlyx> > {
|
||||
public:
|
||||
///
|
||||
FormAboutlyx(Dialog &);
|
||||
|
||||
private:
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
/// not needed.
|
||||
virtual void update() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_aboutlyx_version> version_;
|
||||
///
|
||||
boost::scoped_ptr<FD_aboutlyx_credits> credits_;
|
||||
///
|
||||
boost::scoped_ptr<FD_aboutlyx_license> license_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMABOUTLYX_H
|
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* \file FormBibitem.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormBibitem.h"
|
||||
#include "ControlCommand.h"
|
||||
#include "forms/form_bibitem.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "support/lstrings.h" // compare
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::compare;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
|
||||
|
||||
FormBibitem::FormBibitem(Dialog & parent)
|
||||
: base_class(parent, _("Bibliography Entry Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormBibitem::build()
|
||||
{
|
||||
dialog_.reset(build_bibitem(this));
|
||||
|
||||
fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
|
||||
|
||||
setPrehandler(dialog_->input_key);
|
||||
setPrehandler(dialog_->input_label);
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(dialog_->input_key);
|
||||
bcview().addReadOnly(dialog_->input_label);
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("Key used within LyX document.");
|
||||
tooltips().init(dialog_->input_key, str);
|
||||
str = _("Label used for final output.");
|
||||
tooltips().init(dialog_->input_label, str);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
|
||||
{
|
||||
// minimal validation
|
||||
if (!compare(fl_get_input(dialog_->input_key), ""))
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
void FormBibitem::update()
|
||||
{
|
||||
fl_set_input(dialog_->input_key,
|
||||
controller().params().getContents().c_str());
|
||||
fl_set_input(dialog_->input_label,
|
||||
controller().params().getOptions().c_str());
|
||||
}
|
||||
|
||||
|
||||
void FormBibitem::apply()
|
||||
{
|
||||
controller().params().setContents(fl_get_input(dialog_->input_key));
|
||||
controller().params().setOptions(fl_get_input(dialog_->input_label));
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,45 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormBibitem.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMBIBITEM_H
|
||||
#define FORMBIBITEM_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlCommand;
|
||||
struct FD_bibitem;
|
||||
|
||||
/**
|
||||
* For bibliography entry editing
|
||||
*/
|
||||
class FormBibitem : public FormController<ControlCommand, FormView<FD_bibitem> > {
|
||||
public:
|
||||
///
|
||||
FormBibitem(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMBIBITEM_H
|
@ -1,280 +0,0 @@
|
||||
/**
|
||||
* \file FormBibtex.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author John Levon
|
||||
* \author Herbert Voß
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormBibtex.h"
|
||||
#include "ControlBibtex.h"
|
||||
#include "forms/form_bibtex.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::changeExtension;
|
||||
using support::compare;
|
||||
using support::FileFilterList;
|
||||
using support::getStringFromVector;
|
||||
using support::getVectorFromString;
|
||||
using support::onlyFilename;
|
||||
using support::split;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlBibtex, FormView<FD_bibtex> > base_class;
|
||||
|
||||
FormBibtex::FormBibtex(Dialog & parent)
|
||||
: base_class(parent, _("BibTeX Bibliography"))
|
||||
{}
|
||||
|
||||
|
||||
void FormBibtex::build()
|
||||
{
|
||||
dialog_.reset(build_bibtex(this));
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->input_database);
|
||||
bcview().addReadOnly(dialog_->button_database_browse);
|
||||
bcview().addReadOnly(dialog_->button_style_browse);
|
||||
bcview().addReadOnly(dialog_->button_rescan);
|
||||
bcview().addReadOnly(dialog_->input_style);
|
||||
bcview().addReadOnly(dialog_->check_bibtotoc);
|
||||
bcview().addReadOnly(dialog_->choice_btprint);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_database);
|
||||
setPrehandler(dialog_->input_style);
|
||||
|
||||
fl_set_input_return(dialog_->input_database, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_style, FL_RETURN_CHANGED);
|
||||
|
||||
// callback for double click in browser
|
||||
fl_set_browser_dblclick_callback(dialog_->browser_styles,
|
||||
C_FormDialogView_InputCB, 2);
|
||||
|
||||
fl_addto_choice(dialog_->choice_btprint,
|
||||
_(" all cited references "
|
||||
"| all uncited references "
|
||||
"| all references ").c_str());
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("The database you want to cite from. Insert it "
|
||||
"without the default extension \".bib\". Use comma "
|
||||
"to separate databases.");
|
||||
tooltips().init(dialog_->button_database_browse, str);
|
||||
|
||||
str = _("Browse directory for BibTeX stylefiles");
|
||||
tooltips().init(dialog_->button_style_browse, str);
|
||||
|
||||
str = _("The BibTeX style to use (only one allowed). Insert it without "
|
||||
"the default extension \".bst\" and without path.");
|
||||
tooltips().init(dialog_->input_style, str);
|
||||
|
||||
str = _("Select if the bibliography should appear in the Table "
|
||||
"of Contents");
|
||||
tooltips().init(dialog_->check_bibtotoc, str);
|
||||
|
||||
str = _("Double click to choose a BibTeX style from the list.");
|
||||
tooltips().init(dialog_->browser_styles, str);
|
||||
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// Work-around xforms' bug; enable tooltips for browser widgets.
|
||||
setPrehandler(dialog_->browser_styles);
|
||||
#endif
|
||||
|
||||
str = _("Updates your TeX system for a new bibstyle list. Only "
|
||||
"the styles which are in directories where TeX finds them "
|
||||
"are listed!");
|
||||
tooltips().init(dialog_->button_rescan, str);
|
||||
|
||||
str = _("The bibliography section contains...");
|
||||
tooltips().init(dialog_->choice_btprint, str);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long ob_value)
|
||||
{
|
||||
if (ob == dialog_->button_database_browse) {
|
||||
// When browsing, take the first file only
|
||||
string const in_name = getString(dialog_->input_database);
|
||||
string out_name = controller().browseBib("");
|
||||
if (!out_name.empty()) {
|
||||
// add the database to any existing ones
|
||||
if (!in_name.empty())
|
||||
out_name = in_name + ',' + out_name;
|
||||
|
||||
fl_set_input(dialog_->input_database, out_name.c_str());
|
||||
}
|
||||
|
||||
} else if (ob == dialog_->button_style_browse) {
|
||||
string const in_name = getString(dialog_->input_style);
|
||||
string const style = controller().browseBst(in_name);
|
||||
if (!style.empty()) {
|
||||
fl_set_input(dialog_->input_style, style.c_str());
|
||||
}
|
||||
|
||||
} else if (ob == dialog_->browser_styles && ob_value == 2) {
|
||||
// double clicked in styles browser
|
||||
string const style = getString(dialog_->browser_styles);
|
||||
if (style.empty()) {
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
} else {
|
||||
fl_set_input(dialog_->input_style,
|
||||
changeExtension(style, "").c_str());
|
||||
}
|
||||
// reset the browser so that the following
|
||||
// single-click callback doesn't do anything
|
||||
fl_deselect_browser(dialog_->browser_styles);
|
||||
|
||||
} else if (ob == dialog_->button_rescan) {
|
||||
fl_clear_browser(dialog_->browser_styles);
|
||||
controller().rescanBibStyles();
|
||||
vector<string> styles;
|
||||
controller().getBibStyles(styles);
|
||||
fl_add_browser_line(dialog_->browser_styles,
|
||||
getStringFromVector(styles, "\n").c_str());
|
||||
}
|
||||
|
||||
// with an empty database nothing makes sense ...
|
||||
if (!compare(fl_get_input(dialog_->input_database), "")) {
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
void FormBibtex::update()
|
||||
{
|
||||
fl_set_input(dialog_->input_database,
|
||||
controller().params().getContents().c_str());
|
||||
|
||||
string bibstyle = controller().getStylefile();
|
||||
|
||||
bool const bibtopic = controller().usingBibtopic();
|
||||
fl_set_button(dialog_->check_bibtotoc,
|
||||
controller().bibtotoc() && !bibtopic);
|
||||
setEnabled(dialog_->check_bibtotoc, !bibtopic);
|
||||
|
||||
fl_set_input(dialog_->input_style, bibstyle.c_str());
|
||||
|
||||
string btprint = controller().params().getSecOptions();
|
||||
int btp = 1;
|
||||
if (btprint == "btPrintNotCited")
|
||||
btp = 2;
|
||||
else if (btprint == "btPrintAll")
|
||||
btp = 3;
|
||||
|
||||
fl_set_choice(dialog_->choice_btprint, btp);
|
||||
setEnabled(dialog_->choice_btprint, bibtopic);
|
||||
|
||||
vector<string> styles;
|
||||
controller().getBibStyles(styles);
|
||||
|
||||
fl_clear_browser(dialog_->browser_styles);
|
||||
fl_add_browser_line(dialog_->browser_styles,
|
||||
getStringFromVector(styles, "\n").c_str());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
string const unique_and_no_extensions(string const & str_in)
|
||||
{
|
||||
vector<string> dbase = getVectorFromString(str_in);
|
||||
for (vector<string>::iterator it = dbase.begin();
|
||||
it != dbase.end(); ++it) {
|
||||
*it = changeExtension(*it, string());
|
||||
}
|
||||
eliminate_duplicates(dbase);
|
||||
return getStringFromVector(dbase);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void FormBibtex::apply()
|
||||
{
|
||||
string const db = getString(dialog_->input_database);
|
||||
if (db.empty()) {
|
||||
// no database -> no bibtex-command and no options!
|
||||
controller().params().setContents("");
|
||||
controller().params().setOptions("");
|
||||
controller().params().setSecOptions("");
|
||||
return;
|
||||
}
|
||||
|
||||
controller().params().setContents(unique_and_no_extensions(db));
|
||||
|
||||
// empty is valid!
|
||||
string bibstyle = getString(dialog_->input_style);
|
||||
if (!bibstyle.empty()) {
|
||||
// save the BibTeX style without any ".bst" extension
|
||||
bibstyle = changeExtension(onlyFilename(bibstyle), "");
|
||||
}
|
||||
|
||||
bool const addtotoc = fl_get_button(dialog_->check_bibtotoc);
|
||||
string const bibtotoc = addtotoc ? "bibtotoc" : "";
|
||||
if (addtotoc && !bibstyle.empty()) {
|
||||
// Both bibtotoc and style.
|
||||
controller().params().setOptions(bibtotoc + ',' + bibstyle);
|
||||
|
||||
} else {
|
||||
// At least one of addtotoc and bibstyle is empty.
|
||||
// No harm to output both!
|
||||
controller().params().setOptions(bibtotoc + bibstyle);
|
||||
}
|
||||
|
||||
// bibtopic allows three kinds of sections:
|
||||
// 1. sections that include all cited references of the database(s)
|
||||
// 2. sec. that include all uncited references of the database(s)
|
||||
// 3. sec. that include all references of the database(s), cited or not
|
||||
if (controller().usingBibtopic()){
|
||||
int btp = fl_get_choice(dialog_->choice_btprint);
|
||||
switch (btp) {
|
||||
case 1:
|
||||
controller().params().setSecOptions("btPrintCited");
|
||||
break;
|
||||
case 2:
|
||||
controller().params().setSecOptions("btPrintNotCited");
|
||||
break;
|
||||
case 3:
|
||||
controller().params().setSecOptions("btPrintAll");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
controller().params().setSecOptions("");
|
||||
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,45 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormBibtex.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMBIBTEX_H
|
||||
#define FORMBIBTEX_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlBibtex;
|
||||
struct FD_bibtex;
|
||||
|
||||
/**
|
||||
* For bibtex database setting
|
||||
*/
|
||||
class FormBibtex : public FormController<ControlBibtex, FormView<FD_bibtex> > {
|
||||
public:
|
||||
///
|
||||
FormBibtex(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMBIBTEX_H
|
@ -1,295 +0,0 @@
|
||||
/**
|
||||
* \file FormBox.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna (Minipage stuff)
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormBox.h"
|
||||
#include "ControlBox.h"
|
||||
#include "forms/form_box.h"
|
||||
#include "controllers/ButtonPolicies.h"
|
||||
#include "controllers/helper_funcs.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "insets/insetbox.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::getStringFromVector;
|
||||
using support::isStrDbl;
|
||||
using support::subst;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlBox, FormView<FD_box> > base_class;
|
||||
|
||||
FormBox::FormBox(Dialog & parent)
|
||||
: base_class(parent, _("Box Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormBox::build()
|
||||
{
|
||||
dialog_.reset(build_box(this));
|
||||
|
||||
box_gui_tokens(ids_, gui_names_);
|
||||
|
||||
for (unsigned int i = 0; i < gui_names_.size(); ++i) {
|
||||
fl_addto_choice(dialog_->choice_type, gui_names_[i].c_str());
|
||||
}
|
||||
|
||||
string str = _("Frameless: No border\n"
|
||||
"Boxed: Rectangular\n"
|
||||
"ovalbox: Oval, thin border\n"
|
||||
"Ovalbox: Oval, thick border\n"
|
||||
"Shadowbox: Box casting shadow\n"
|
||||
"Doublebox: Double line border");
|
||||
tooltips().init(dialog_->choice_type, str);
|
||||
|
||||
bcview().addReadOnly(dialog_->check_inner_box);
|
||||
|
||||
str = _("The inner box may be a parbox or a minipage,\n"
|
||||
"with appropriate arguments from this dialog.");
|
||||
tooltips().init(dialog_->check_inner_box, str);
|
||||
|
||||
bcview().addReadOnly(dialog_->radio_parbox);
|
||||
bcview().addReadOnly(dialog_->radio_minipage);
|
||||
|
||||
bcview().addReadOnly(dialog_->choice_pos);
|
||||
fl_addto_choice(dialog_->choice_pos, _("Top").c_str());
|
||||
fl_addto_choice(dialog_->choice_pos, _("Middle").c_str());
|
||||
fl_addto_choice(dialog_->choice_pos, _("Bottom").c_str());
|
||||
|
||||
bcview().addReadOnly(dialog_->choice_inner_pos);
|
||||
fl_addto_choice(dialog_->choice_inner_pos, _("Top").c_str());
|
||||
fl_addto_choice(dialog_->choice_inner_pos, _("Middle").c_str());
|
||||
fl_addto_choice(dialog_->choice_inner_pos, _("Bottom").c_str());
|
||||
fl_addto_choice(dialog_->choice_inner_pos, _("Stretch").c_str());
|
||||
|
||||
bcview().addReadOnly(dialog_->choice_hor_pos);
|
||||
fl_addto_choice(dialog_->choice_hor_pos, _("Left").c_str());
|
||||
fl_addto_choice(dialog_->choice_hor_pos, _("Center").c_str());
|
||||
fl_addto_choice(dialog_->choice_hor_pos, _("Right").c_str());
|
||||
fl_addto_choice(dialog_->choice_hor_pos, _("Stretch").c_str());
|
||||
|
||||
bcview().addReadOnly(dialog_->input_width);
|
||||
bcview().addReadOnly(dialog_->choice_width_unit);
|
||||
bcview().addReadOnly(dialog_->choice_special);
|
||||
|
||||
box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
|
||||
for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
|
||||
fl_addto_choice(dialog_->choice_special, gui_names_spec_[i].c_str());
|
||||
}
|
||||
|
||||
string choice = getStringFromVector(getLatexUnits(), "|");
|
||||
fl_addto_choice(dialog_->choice_width_unit,
|
||||
subst(choice, "%", "%%").c_str());
|
||||
|
||||
bcview().addReadOnly(dialog_->input_height);
|
||||
bcview().addReadOnly(dialog_->choice_height_unit);
|
||||
bcview().addReadOnly(dialog_->choice_height_special);
|
||||
for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
|
||||
fl_addto_choice(dialog_->choice_height_special,
|
||||
gui_names_spec_[i].c_str());
|
||||
}
|
||||
|
||||
choice = getStringFromVector(getLatexUnits(), "|");
|
||||
fl_addto_choice(dialog_->choice_height_unit,
|
||||
subst(choice, "%", "%%").c_str());
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_cancel);
|
||||
}
|
||||
|
||||
|
||||
void FormBox::update()
|
||||
{
|
||||
string type(controller().params().type);
|
||||
for (unsigned int i = 0; i < gui_names_.size(); ++i) {
|
||||
if (type == ids_[i])
|
||||
fl_set_choice_text(dialog_->choice_type, gui_names_[i].c_str());
|
||||
}
|
||||
|
||||
fl_set_button(dialog_->check_inner_box, controller().params().inner_box);
|
||||
if (controller().params().type == "Frameless")
|
||||
setEnabled(dialog_->check_inner_box, false);
|
||||
|
||||
char c = controller().params().pos;
|
||||
fl_set_choice(dialog_->choice_pos, string("tcb").find(c, 0) + 1);
|
||||
c = controller().params().inner_pos;
|
||||
fl_set_choice(dialog_->choice_inner_pos, string("tcbs").find(c, 0) + 1);
|
||||
c = controller().params().hor_pos;
|
||||
fl_set_choice(dialog_->choice_hor_pos, string("lcrs").find(c, 0) + 1);
|
||||
setEnabled(dialog_->choice_pos, controller().params().inner_box);
|
||||
setEnabled(dialog_->choice_inner_pos, controller().params().inner_box);
|
||||
setEnabled(dialog_->choice_hor_pos, !controller().params().inner_box);
|
||||
|
||||
fl_set_button(dialog_->radio_parbox, controller().params().use_parbox);
|
||||
fl_set_button(dialog_->radio_minipage, !controller().params().use_parbox);
|
||||
setEnabled(dialog_->radio_parbox, controller().params().inner_box);
|
||||
setEnabled(dialog_->radio_minipage, controller().params().inner_box);
|
||||
|
||||
LyXLength len(controller().params().width);
|
||||
fl_set_input(dialog_->input_width, convert<string>(len.value()).c_str());
|
||||
fl_set_choice(dialog_->choice_width_unit, len.unit() + 1);
|
||||
string special(controller().params().special);
|
||||
for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
|
||||
if (special == ids_spec_[i])
|
||||
fl_set_choice_text(dialog_->choice_special,
|
||||
gui_names_spec_[i].c_str());
|
||||
}
|
||||
// Special width unit must be default for general units to be enabled
|
||||
if (controller().params().special != "none")
|
||||
setEnabled(dialog_->choice_width_unit, false);
|
||||
setEnabled(dialog_->choice_special, !controller().params().inner_box);
|
||||
|
||||
LyXLength ht(controller().params().height);
|
||||
fl_set_input(dialog_->input_height, convert<string>(ht.value()).c_str());
|
||||
fl_set_choice(dialog_->choice_height_unit, ht.unit() + 1);
|
||||
string const height_special(controller().params().height_special);
|
||||
for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
|
||||
if (height_special == ids_spec_[i])
|
||||
fl_set_choice_text(dialog_->choice_height_special,
|
||||
gui_names_spec_[i].c_str());
|
||||
}
|
||||
setEnabled(dialog_->input_height, controller().params().inner_box);
|
||||
setEnabled(dialog_->choice_height_unit, controller().params().inner_box);
|
||||
setEnabled(dialog_->choice_height_special, controller().params().inner_box);
|
||||
// Same here
|
||||
if (height_special != "none")
|
||||
setEnabled(dialog_->choice_height_unit, false);
|
||||
}
|
||||
|
||||
|
||||
void FormBox::apply()
|
||||
{
|
||||
int i = fl_get_choice(dialog_->choice_type);
|
||||
controller().params().type = ids_[i - 1];
|
||||
|
||||
controller().params().inner_box = fl_get_button(dialog_->check_inner_box);
|
||||
controller().params().use_parbox =
|
||||
fl_get_button(dialog_->radio_parbox);
|
||||
controller().params().width =
|
||||
LyXLength(getLengthFromWidgets(dialog_->input_width,
|
||||
dialog_->choice_width_unit));
|
||||
|
||||
controller().params().pos =
|
||||
"tcb"[fl_get_choice(dialog_->choice_pos) - 1];
|
||||
controller().params().inner_pos =
|
||||
"tcbs"[fl_get_choice(dialog_->choice_inner_pos) - 1];
|
||||
controller().params().hor_pos =
|
||||
"lcrs"[fl_get_choice(dialog_->choice_hor_pos) - 1];
|
||||
|
||||
i = fl_get_choice(dialog_->choice_special);
|
||||
controller().params().special = ids_spec_[i - 1];
|
||||
|
||||
controller().params().height =
|
||||
LyXLength(getLengthFromWidgets(dialog_->input_height,
|
||||
dialog_->choice_height_unit));
|
||||
i = fl_get_choice(dialog_->choice_height_special);
|
||||
controller().params().height_special = ids_spec_[i - 1];
|
||||
}
|
||||
|
||||
ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->check_inner_box) {
|
||||
setEnabled(dialog_->choice_pos,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->radio_parbox,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->radio_minipage,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->choice_width_unit, true);
|
||||
setEnabled(dialog_->choice_special,
|
||||
!fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->input_height,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->choice_height_unit,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->choice_height_special,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->choice_hor_pos,
|
||||
!fl_get_button(dialog_->check_inner_box));
|
||||
setEnabled(dialog_->choice_inner_pos,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
|
||||
// Reset to defaults to not confuse users:
|
||||
if (fl_get_button(dialog_->check_inner_box))
|
||||
fl_set_choice(dialog_->choice_special, NONE);
|
||||
else
|
||||
fl_set_choice(dialog_->choice_height_special, NONE);
|
||||
}
|
||||
|
||||
if (ob == dialog_->choice_special || ob == dialog_->check_inner_box)
|
||||
setEnabled(dialog_->choice_width_unit,
|
||||
fl_get_choice(dialog_->choice_special) == NONE);
|
||||
if (ob == dialog_->choice_height_special || ob == dialog_->check_inner_box)
|
||||
if (fl_get_choice(dialog_->choice_height_special) != NONE)
|
||||
setEnabled(dialog_->choice_height_unit, false);
|
||||
else
|
||||
setEnabled(dialog_->choice_height_unit,
|
||||
fl_get_button(dialog_->check_inner_box));
|
||||
|
||||
// An inner box (parbox, minipage) is mandatory if no outer box
|
||||
if (ob == dialog_->choice_type) {
|
||||
int i = fl_get_choice(dialog_->choice_type);
|
||||
if (ids_[i - 1] == "Frameless") {
|
||||
setEnabled(dialog_->check_inner_box, false);
|
||||
fl_set_button(dialog_->check_inner_box, true);
|
||||
} else {
|
||||
setEnabled(dialog_->check_inner_box, true);
|
||||
}
|
||||
}
|
||||
// disallow senseless data, warnings if input is senseless
|
||||
if (ob == dialog_->input_width) {
|
||||
string const input = getString(dialog_->input_width);
|
||||
bool const invalid = !isValidLength(input) && !isStrDbl(input);
|
||||
if (invalid) {
|
||||
postWarning(_("Invalid length!"));
|
||||
return ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
}
|
||||
if (ob == dialog_->input_height) {
|
||||
string const input = getString(dialog_->input_height);
|
||||
bool const invalid = !isValidLength(input) && !isStrDbl(input);
|
||||
if (invalid) {
|
||||
postWarning(_("Invalid length!"));
|
||||
return ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
}
|
||||
if (ob == dialog_->button_defaults) {
|
||||
fl_set_button(dialog_->check_inner_box, true);
|
||||
fl_set_button(dialog_->radio_parbox, false);
|
||||
fl_set_input(dialog_->input_width, "100");
|
||||
fl_set_choice(dialog_->choice_width_unit, LyXLength::PCW + 1);
|
||||
fl_set_choice(dialog_->choice_special, NONE);
|
||||
fl_set_input(dialog_->input_height, "1");
|
||||
fl_set_choice(dialog_->choice_height_special, TOTALHEIGHT);
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,59 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormBox.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMBOX_H
|
||||
#define FORMBOX_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlBox;
|
||||
struct FD_box;
|
||||
|
||||
/** This class provides an XForms implementation of the Box Dialog.
|
||||
*/
|
||||
class FormBox : public FormController<ControlBox, FormView<FD_box> > {
|
||||
public:
|
||||
/// Constructor
|
||||
FormBox(Dialog &);
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input( FL_OBJECT *, long);
|
||||
///
|
||||
std::vector<std::string> ids_;
|
||||
///
|
||||
std::vector<std::string> gui_names_;
|
||||
///
|
||||
std::vector<std::string> ids_spec_;
|
||||
///
|
||||
std::vector<std::string> gui_names_spec_;
|
||||
///
|
||||
enum Specials {
|
||||
NONE = 1,
|
||||
HEIGHT,
|
||||
DEPTH,
|
||||
TOTALHEIGHT,
|
||||
WIDTH
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMBOX_H
|
@ -1,80 +0,0 @@
|
||||
/**
|
||||
* \file FormBranch.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormBranch.h"
|
||||
#include "forms/form_branch.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "BranchList.h"
|
||||
|
||||
#include "controllers/ControlBranch.h"
|
||||
|
||||
#include "insets/insetbranch.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlBranch, FormView<FD_branch> > base_class;
|
||||
|
||||
FormBranch::FormBranch(Dialog & parent)
|
||||
: base_class(parent, _("Branch Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormBranch::build()
|
||||
{
|
||||
dialog_.reset(build_branch(this));
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_cancel);
|
||||
}
|
||||
|
||||
|
||||
void FormBranch::update()
|
||||
{
|
||||
typedef BranchList::const_iterator const_iterator;
|
||||
|
||||
BranchList const & branchlist = controller().branchlist();
|
||||
string const cur_branch = controller().params().branch;
|
||||
|
||||
fl_clear_choice(dialog_->choice_branch);
|
||||
|
||||
const_iterator const begin = branchlist.begin();
|
||||
const_iterator const end = branchlist.end();
|
||||
int id = 1;
|
||||
int count = 1;
|
||||
for (const_iterator it = begin; it != end; ++it, ++count) {
|
||||
string const & branch = it->getBranch();
|
||||
fl_addto_choice(dialog_->choice_branch, branch.c_str());
|
||||
|
||||
if (cur_branch == branch)
|
||||
id = count;
|
||||
}
|
||||
fl_set_choice(dialog_->choice_branch, id);
|
||||
}
|
||||
|
||||
|
||||
void FormBranch::apply()
|
||||
{
|
||||
string const type = fl_get_choice_text(dialog_->choice_branch);
|
||||
controller().params().branch = type;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,41 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormBranch.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMBRANCH_H
|
||||
#define FORMBRANCH_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlBranch;
|
||||
struct FD_branch;
|
||||
|
||||
/** This class provides an XForms implementation of the Branch Dialog.
|
||||
*/
|
||||
class FormBranch : public FormController<ControlBranch, FormView<FD_branch> > {
|
||||
public:
|
||||
/// Constructor
|
||||
FormBranch(Dialog &);
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMBRANCH_H
|
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* \file FormBrowser.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormBrowser.h"
|
||||
#include "forms/form_browser.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
FormBrowser::FormBrowser(Dialog & parent,
|
||||
string const & title, bool allowResize)
|
||||
: FormView<FD_browser>(parent, title, allowResize)
|
||||
{}
|
||||
|
||||
|
||||
void FormBrowser::build()
|
||||
{
|
||||
dialog_.reset(build_browser(this));
|
||||
|
||||
// Manage the close button
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,40 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormBrowser.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMBROWSER_H
|
||||
#define FORMBROWSER_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
struct FD_browser;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of a read only
|
||||
* text browser.
|
||||
*/
|
||||
|
||||
class FormBrowser : public FormView<FD_browser> {
|
||||
public:
|
||||
///
|
||||
FormBrowser(Dialog &, std::string const &, bool allowResize = true);
|
||||
private:
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMBROWSER_H
|
@ -1,81 +0,0 @@
|
||||
/**
|
||||
* \file FormChanges.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormChanges.h"
|
||||
#include "ControlChanges.h"
|
||||
#include "forms/form_changes.h"
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlChanges, FormView<FD_changes> > base_class;
|
||||
|
||||
FormChanges::FormChanges(Dialog & parent)
|
||||
: base_class(parent, _("Merge Changes"))
|
||||
{}
|
||||
|
||||
|
||||
void FormChanges::build()
|
||||
{
|
||||
dialog_.reset(build_changes(this));
|
||||
|
||||
// Manage the cancel/close buttons
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->button_accept);
|
||||
bcview().addReadOnly(dialog_->button_reject);
|
||||
}
|
||||
|
||||
|
||||
void FormChanges::update()
|
||||
{
|
||||
if (!dialog_.get()) return;
|
||||
bool exist = controller().changed();
|
||||
setEnabled(dialog_->button_accept, exist);
|
||||
setEnabled(dialog_->button_reject, exist);
|
||||
setEnabled(dialog_->button_next, exist);
|
||||
|
||||
string const author = exist ? controller().getChangeAuthor() : "";
|
||||
fl_set_object_label(dialog_->text_author, author.c_str());
|
||||
|
||||
string const date = exist ? controller().getChangeDate() : "";
|
||||
fl_set_object_label(dialog_->text_date, date.c_str());
|
||||
|
||||
// Yes, this is needed.
|
||||
fl_redraw_form(form());
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormChanges::input(FL_OBJECT * obj, long)
|
||||
{
|
||||
if (obj == dialog_->button_accept)
|
||||
controller().accept();
|
||||
else if (obj == dialog_->button_reject)
|
||||
controller().reject();
|
||||
else if (obj == dialog_->button_next)
|
||||
controller().find();
|
||||
update();
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,46 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormChanges.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMCHANGES_H
|
||||
#define FORMCHANGES_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlChanges;
|
||||
struct FD_changes;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the Merge Changes Dialog.
|
||||
*/
|
||||
class FormChanges
|
||||
: public FormController<ControlChanges, FormView<FD_changes> > {
|
||||
public:
|
||||
FormChanges(Dialog &);
|
||||
|
||||
private:
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// update the dialog
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMCHANGES_H
|
@ -1,190 +0,0 @@
|
||||
/**
|
||||
* \file FormCharacter.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormCharacter.h"
|
||||
#include "forms/form_character.h"
|
||||
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/frnt_lang.h"
|
||||
#include "controllers/helper_funcs.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
#include "combox.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::getStringFromVector;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
typedef FormController<ControlCharacter, FormView<FD_character> > base_class;
|
||||
|
||||
FormCharacter::FormCharacter(Dialog & parent)
|
||||
: base_class(parent, _("Text Style"), false)
|
||||
{}
|
||||
|
||||
|
||||
void FormCharacter::build()
|
||||
{
|
||||
dialog_.reset(build_character(this));
|
||||
|
||||
vector<FamilyPair> const family = getFamilyData();
|
||||
vector<SeriesPair> const series = getSeriesData();
|
||||
vector<ShapePair> const shape = getShapeData();
|
||||
vector<SizePair> const size = getSizeData();
|
||||
vector<BarPair> const bar = getBarData();
|
||||
vector<ColorPair> const color = getColorData();
|
||||
vector<LanguagePair> const langs = getLanguageData(true);
|
||||
|
||||
// Store the identifiers for later
|
||||
family_ = getSecond(family);
|
||||
series_ = getSecond(series);
|
||||
shape_ = getSecond(shape);
|
||||
size_ = getSecond(size);
|
||||
bar_ = getSecond(bar);
|
||||
color_ = getSecond(color);
|
||||
lang_ = getSecond(langs);
|
||||
|
||||
// create a string of entries " entry1 | entry2 | entry3 | entry4 "
|
||||
// with which to initialise the xforms choice object.
|
||||
string choice = ' ' + getStringFromVector(getFirst(family), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_family, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(series), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_series, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(shape), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_shape, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(size), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_size, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(bar), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_bar, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(color), " | ") + ' ';
|
||||
fl_addto_choice(dialog_->choice_color, choice.c_str());
|
||||
|
||||
choice = ' ' + getStringFromVector(getFirst(langs), " | ") + ' ';
|
||||
fl_addto_combox(dialog_->combox_language, choice.c_str());
|
||||
fl_set_combox_browser_height(dialog_->combox_language, 250);
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().addReadOnly(dialog_->check_toggle_all);
|
||||
}
|
||||
|
||||
|
||||
void FormCharacter::apply()
|
||||
{
|
||||
if (!form()) return;
|
||||
|
||||
int pos = fl_get_choice(dialog_->choice_family);
|
||||
controller().setFamily(family_[pos - 1]);
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_series);
|
||||
controller().setSeries(series_[pos - 1]);
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_shape);
|
||||
controller().setShape(shape_[pos - 1]);
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_size);
|
||||
controller().setSize(size_[pos - 1]);
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_bar);
|
||||
controller().setBar(bar_[pos - 1]);
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_color);
|
||||
controller().setColor(color_[pos - 1]);
|
||||
|
||||
pos = fl_get_combox(dialog_->combox_language);
|
||||
controller().setLanguage(lang_[pos - 1]);
|
||||
|
||||
bool const toggleall = fl_get_button(dialog_->check_toggle_all);
|
||||
controller().setToggleAll(toggleall);
|
||||
}
|
||||
|
||||
|
||||
void FormCharacter::update()
|
||||
{
|
||||
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);
|
||||
|
||||
pos = int(findPos(lang_, controller().getLanguage()));
|
||||
fl_set_combox(dialog_->combox_language, pos+1);
|
||||
|
||||
fl_set_button(dialog_->check_toggle_all, controller().getToggleAll());
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormCharacter::input(FL_OBJECT *, long)
|
||||
{
|
||||
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
int pos = fl_get_choice(dialog_->choice_family);
|
||||
if (family_[pos - 1] != LyXFont::IGNORE_FAMILY)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_series);
|
||||
if (series_[pos - 1] != LyXFont::IGNORE_SERIES)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_shape);
|
||||
if (shape_[pos - 1] != LyXFont::IGNORE_SHAPE)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_size);
|
||||
if (size_[pos - 1] != LyXFont::IGNORE_SIZE)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_bar);
|
||||
if (bar_[pos - 1] != IGNORE)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_color);
|
||||
if (color_[pos - 1] != LColor::ignore)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_combox(dialog_->combox_language);
|
||||
if (lang_[pos - 1] != "No change")
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,69 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormCharacter.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_CHARACTER_H
|
||||
#define FORM_CHARACTER_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "ControlCharacter.h" // for ControlCharacter enum
|
||||
|
||||
#include "LColor.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
struct FD_character;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the Character Dialog.
|
||||
* The character dialog allows users to change the character settings
|
||||
* in their documents.
|
||||
*/
|
||||
class FormCharacter
|
||||
: public FormController<ControlCharacter, FormView<FD_character> > {
|
||||
public:
|
||||
///
|
||||
FormCharacter(Dialog &);
|
||||
private:
|
||||
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
///
|
||||
std::vector<LyXFont::FONT_FAMILY> family_;
|
||||
///
|
||||
std::vector<LyXFont::FONT_SERIES> series_;
|
||||
///
|
||||
std::vector<LyXFont::FONT_SHAPE> shape_;
|
||||
///
|
||||
std::vector<LyXFont::FONT_SIZE> size_;
|
||||
///
|
||||
std::vector<FONT_STATE> bar_;
|
||||
///
|
||||
std::vector<LColor_color> color_;
|
||||
///
|
||||
std::vector<std::string> lang_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,533 +0,0 @@
|
||||
/**
|
||||
* \file FormCitation.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormCitation.h"
|
||||
#include "ControlCitation.h"
|
||||
#include "forms/form_citation.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "bufferparams.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::find;
|
||||
using std::max;
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::swap;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::getStringFromVector;
|
||||
using support::getVectorFromString;
|
||||
using support::trim;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
// shamelessly stolen from Menubar_pimpl.C
|
||||
int string_width(string const & str)
|
||||
{
|
||||
return fl_get_string_widthTAB(FL_NORMAL_STYLE, FL_NORMAL_SIZE,
|
||||
str.c_str(),
|
||||
static_cast<int>(str.length()));
|
||||
}
|
||||
|
||||
|
||||
void fillChoice(FD_citation * dialog, vector<string> vec)
|
||||
{
|
||||
// Check whether the current contents of the browser will be
|
||||
// changed by loading the contents of the vec...
|
||||
vector<string> const choice_style = getVector(dialog->choice_style);
|
||||
|
||||
if (vec == choice_style)
|
||||
return;
|
||||
|
||||
// They will be changed. Proceed
|
||||
bool const noVec = vec.empty();
|
||||
string const str = noVec ? string() : getStringFromVector(vec, "|");
|
||||
|
||||
fl_clear_choice(dialog->choice_style);
|
||||
fl_addto_choice(dialog->choice_style, str.c_str());
|
||||
setEnabled(dialog->choice_style, !noVec);
|
||||
}
|
||||
|
||||
|
||||
void updateStyle(FD_citation * dialog, string command)
|
||||
{
|
||||
// Find the style of the citekeys
|
||||
vector<biblio::CiteStyle> const & styles =
|
||||
ControlCitation::getCiteStyles();
|
||||
biblio::CitationStyle const cs(command);
|
||||
|
||||
vector<biblio::CiteStyle>::const_iterator cit =
|
||||
find(styles.begin(), styles.end(), cs.style);
|
||||
|
||||
// Use this to initialise the GUI
|
||||
bool const noStyles = cit == styles.end();
|
||||
int const index = 1 + ( noStyles ? 0 : int(cit - styles.begin()) );
|
||||
fl_set_choice(dialog->choice_style, index);
|
||||
|
||||
// Disable if there are no styles, otherwise use cs member settings.
|
||||
fl_set_button(dialog->check_full_author_list, !noStyles && cs.full);
|
||||
fl_set_button(dialog->check_force_uppercase, !noStyles && cs.forceUCase);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlCitation, FormView<FD_citation> > base_class;
|
||||
|
||||
|
||||
FormCitation::FormCitation(Dialog & parent)
|
||||
: base_class(parent, _("Citation"))
|
||||
{}
|
||||
|
||||
|
||||
void FormCitation::apply()
|
||||
{
|
||||
string command = "cite";
|
||||
if (isActive(dialog_->choice_style)) {
|
||||
vector<biblio::CiteStyle> const & styles =
|
||||
ControlCitation::getCiteStyles();
|
||||
|
||||
int const choice =
|
||||
std::max(0, fl_get_choice(dialog_->choice_style) - 1);
|
||||
bool const full =
|
||||
fl_get_button(dialog_->check_full_author_list);
|
||||
bool const force =
|
||||
fl_get_button(dialog_->check_force_uppercase);
|
||||
|
||||
command =
|
||||
biblio::CitationStyle(styles[choice], full, force)
|
||||
.asLatexStr();
|
||||
|
||||
}
|
||||
|
||||
controller().params().setCmdName(command);
|
||||
controller().params().setContents(getStringFromVector(citekeys));
|
||||
|
||||
string const before = getString(dialog_->input_before);
|
||||
controller().params().setSecOptions(before);
|
||||
|
||||
string const after = getString(dialog_->input_after);
|
||||
controller().params().setOptions(after);
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::hide()
|
||||
{
|
||||
citekeys.clear();
|
||||
bibkeys.clear();
|
||||
|
||||
FormDialogView::hide();
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::build()
|
||||
{
|
||||
dialog_.reset(build_citation(this));
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->button_add);
|
||||
bcview().addReadOnly(dialog_->button_del);
|
||||
bcview().addReadOnly(dialog_->button_up);
|
||||
bcview().addReadOnly(dialog_->button_down);
|
||||
bcview().addReadOnly(dialog_->choice_style);
|
||||
bcview().addReadOnly(dialog_->input_before);
|
||||
bcview().addReadOnly(dialog_->input_after);
|
||||
bcview().addReadOnly(dialog_->check_full_author_list);
|
||||
bcview().addReadOnly(dialog_->check_force_uppercase);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_search);
|
||||
setPrehandler(dialog_->input_before);
|
||||
setPrehandler(dialog_->input_after);
|
||||
|
||||
fl_set_input_return(dialog_->input_after, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_before, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_search, FL_RETURN_END);
|
||||
|
||||
//set up the tooltip mechanism
|
||||
string str = _("Add citation of the selected bibliography entry.");
|
||||
tooltips().init(dialog_->button_add, str);
|
||||
|
||||
str = _("Delete citation of the selected bibliography entry.");
|
||||
tooltips().init(dialog_->button_del, str);
|
||||
|
||||
str = _("Move the selected entry upwards (in the current list).");
|
||||
tooltips().init(dialog_->button_up, str);
|
||||
|
||||
str = _("Move the selected entry downwards (in the current list).");
|
||||
tooltips().init(dialog_->button_down, str);
|
||||
|
||||
str = _("The entries which will be cited. Select them with the arrow buttons from the right browser window.");
|
||||
tooltips().init(dialog_->browser_cite, str);
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// Work-around xforms' bug; enable tooltips for browser widgets.
|
||||
setPrehandler(dialog_->browser_cite);
|
||||
#endif
|
||||
|
||||
str = _("All entries in the database you have loaded (via \"Insert->List / TOC->BibTeX Bibliography\"). Move the ones you want to cite with the arrow buttons into the left browser window.");
|
||||
tooltips().init(dialog_->browser_bib, str);
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// Work-around xforms' bug; enable tooltips for browser widgets.
|
||||
setPrehandler(dialog_->browser_bib);
|
||||
#endif
|
||||
|
||||
str = _("Information about the selected bibliography entry");
|
||||
tooltips().init(dialog_->browser_info, str);
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// Work-around xforms' bug; enable tooltips for browser widgets.
|
||||
setPrehandler(dialog_->browser_info);
|
||||
#endif
|
||||
|
||||
str = _("Here you may select how the citation label should look inside the text (Natbib).");
|
||||
tooltips().init(dialog_->choice_style, str);
|
||||
|
||||
str = _("Activate if you want to print all authors in a citation with more than three authors, and not \"<First Author> et al.\" (Natbib).");
|
||||
tooltips().init(dialog_->check_full_author_list, str);
|
||||
|
||||
str = _("Activate if you want to print the first character of the author name as uppercase (\"Van Gogh\", not \"van Gogh\"). Useful at the beginning of sentences (Natbib).");
|
||||
tooltips().init(dialog_->check_force_uppercase, str);
|
||||
|
||||
str = _("Optional text which appears before the citation, e.g. \"see <Citation>\"");
|
||||
tooltips().init(dialog_->input_before, str);
|
||||
|
||||
str = _("Optional text which appears after the citation, e.g. \"pp. 12\"");
|
||||
tooltips().init(dialog_->input_after, str);
|
||||
|
||||
str = _("Search your database (all fields will be searched).");
|
||||
tooltips().init(dialog_->input_search, str);
|
||||
|
||||
str = _("Activate if you want to have case sensitive search: \"bibtex\" finds \"bibtex\", but not \"BibTeX\".");
|
||||
tooltips().init(dialog_->check_search_case, str);
|
||||
|
||||
str = _("Activate if you want to enter Regular Expressions.");
|
||||
tooltips().init(dialog_->check_search_type, str);
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::findBiblio(biblio::Direction const dir)
|
||||
{
|
||||
string const str = getString(dialog_->input_search);
|
||||
biblio::InfoMap const & theMap = controller().bibkeysInfo();
|
||||
bool const caseSensitive =
|
||||
fl_get_button(dialog_->check_search_case);
|
||||
biblio::Search const type =
|
||||
fl_get_button(dialog_->check_search_type) ?
|
||||
biblio::REGEX : biblio::SIMPLE;
|
||||
|
||||
vector<string>::const_iterator start = bibkeys.begin();
|
||||
int const sel = fl_get_browser(dialog_->browser_bib);
|
||||
if (sel >= 1 && sel <= int(bibkeys.size()))
|
||||
start += sel - 1;
|
||||
|
||||
// Find the NEXT instance...
|
||||
if (dir == biblio::FORWARD)
|
||||
start += 1;
|
||||
|
||||
|
||||
vector<string>::const_iterator const cit =
|
||||
biblio::searchKeys(theMap, bibkeys, str,
|
||||
start, type, dir, caseSensitive);
|
||||
|
||||
if (cit == bibkeys.end())
|
||||
return;
|
||||
|
||||
int const found = int(cit - bibkeys.begin()) + 1;
|
||||
if (found == sel)
|
||||
return;
|
||||
|
||||
// Update the display
|
||||
int const top = max(found - 5, 1);
|
||||
fl_set_browser_topline(dialog_->browser_bib, top);
|
||||
fl_select_browser_line(dialog_->browser_bib, found);
|
||||
input(dialog_->browser_bib, 0);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
biblio::InfoMap const & theMap = controller().bibkeysInfo();
|
||||
|
||||
string topCitekey;
|
||||
if (!citekeys.empty()) topCitekey = citekeys[0];
|
||||
|
||||
if (ob == dialog_->browser_bib) {
|
||||
fl_deselect_browser(dialog_->browser_cite);
|
||||
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_bib);
|
||||
if (sel < 1 || sel > bibkeys.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Put into browser_info the additional info associated with
|
||||
// the selected browser_bib key
|
||||
fl_clear_browser(dialog_->browser_info);
|
||||
|
||||
string const tmp = formatted(biblio::getInfo(theMap,
|
||||
bibkeys[sel - 1]),
|
||||
dialog_->browser_info->w - 10);
|
||||
fl_add_browser_line(dialog_->browser_info, tmp.c_str());
|
||||
|
||||
// Highlight the selected browser_bib key in browser_cite if
|
||||
// present
|
||||
vector<string>::const_iterator cit =
|
||||
find(citekeys.begin(), citekeys.end(), bibkeys[sel - 1]);
|
||||
|
||||
if (cit != citekeys.end()) {
|
||||
int const n = int(cit - citekeys.begin());
|
||||
fl_select_browser_line(dialog_->browser_cite, n + 1);
|
||||
fl_set_browser_topline(dialog_->browser_cite, n + 1);
|
||||
}
|
||||
|
||||
if (!kernel().isBufferReadonly()) {
|
||||
if (cit != citekeys.end()) {
|
||||
setBibButtons(OFF);
|
||||
setCiteButtons(ON);
|
||||
} else {
|
||||
setBibButtons(ON);
|
||||
setCiteButtons(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ob == dialog_->browser_cite) {
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
|
||||
if (sel < 1 || sel > citekeys.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
if (!kernel().isBufferReadonly()) {
|
||||
setBibButtons(OFF);
|
||||
setCiteButtons(ON);
|
||||
}
|
||||
|
||||
// Highlight the selected browser_cite key in browser_bib
|
||||
vector<string>::const_iterator cit =
|
||||
find(bibkeys.begin(), bibkeys.end(), citekeys[sel - 1]);
|
||||
|
||||
if (cit != bibkeys.end()) {
|
||||
int const n = int(cit - bibkeys.begin());
|
||||
fl_select_browser_line(dialog_->browser_bib, n + 1);
|
||||
fl_set_browser_topline(dialog_->browser_bib, n + 1);
|
||||
|
||||
// Put into browser_info the additional info associated
|
||||
// with the selected browser_cite key
|
||||
fl_clear_browser(dialog_->browser_info);
|
||||
string const tmp =
|
||||
formatted(biblio::getInfo(theMap, citekeys[sel - 1]),
|
||||
dialog_->browser_info->w - 10);
|
||||
fl_add_browser_line(dialog_->browser_info, tmp.c_str());
|
||||
}
|
||||
|
||||
} else if (ob == dialog_->button_add) {
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_bib);
|
||||
if (sel < 1 || sel > bibkeys.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Add the selected browser_bib key to browser_cite
|
||||
fl_addto_browser(dialog_->browser_cite,
|
||||
bibkeys[sel - 1].c_str());
|
||||
citekeys.push_back(bibkeys[sel - 1]);
|
||||
|
||||
int const n = int(citekeys.size());
|
||||
fl_select_browser_line(dialog_->browser_cite, n);
|
||||
|
||||
setBibButtons(OFF);
|
||||
setCiteButtons(ON);
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
} else if (ob == dialog_->button_del) {
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
|
||||
if (sel < 1 || sel > citekeys.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Remove the selected key from browser_cite
|
||||
fl_delete_browser_line(dialog_->browser_cite, sel) ;
|
||||
citekeys.erase(citekeys.begin() + sel - 1);
|
||||
|
||||
setBibButtons(ON);
|
||||
setCiteButtons(OFF);
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
} else if (ob == dialog_->button_up) {
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
|
||||
if (sel < 2 || sel > citekeys.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Move the selected key up one line
|
||||
string const tmp = citekeys[sel - 1];
|
||||
|
||||
fl_delete_browser_line(dialog_->browser_cite, sel);
|
||||
swap(citekeys[sel - 2], citekeys[sel - 1]);
|
||||
|
||||
fl_insert_browser_line(dialog_->browser_cite, sel - 1, tmp.c_str());
|
||||
fl_select_browser_line(dialog_->browser_cite, sel - 1);
|
||||
setCiteButtons(ON);
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
} else if (ob == dialog_->button_down) {
|
||||
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
|
||||
if (sel < 1 || sel > citekeys.size() - 1)
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Move the selected key down one line
|
||||
string const tmp = citekeys[sel - 1];
|
||||
|
||||
fl_delete_browser_line(dialog_->browser_cite, sel);
|
||||
swap(citekeys[sel], citekeys[sel - 1]);
|
||||
|
||||
fl_insert_browser_line(dialog_->browser_cite, sel+1, tmp.c_str());
|
||||
fl_select_browser_line(dialog_->browser_cite, sel+1);
|
||||
setCiteButtons(ON);
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
} else if (ob == dialog_->button_previous) {
|
||||
findBiblio(biblio::BACKWARD);
|
||||
} else if (ob == dialog_->button_next) {
|
||||
findBiblio(biblio::FORWARD);
|
||||
} else if (ob == dialog_->input_search) {
|
||||
findBiblio(biblio::FORWARD);
|
||||
} else if (ob == dialog_->choice_style ||
|
||||
ob == dialog_->check_full_author_list ||
|
||||
ob == dialog_->check_force_uppercase ||
|
||||
ob == dialog_->input_before ||
|
||||
ob == dialog_->input_after) {
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
string currentCitekey;
|
||||
if (!citekeys.empty())
|
||||
currentCitekey = citekeys[0];
|
||||
|
||||
if (topCitekey != currentCitekey) {
|
||||
int choice = std::max(1, fl_get_choice(dialog_->choice_style));
|
||||
fillChoice(dialog_.get(),
|
||||
controller().getCiteStrings(currentCitekey));
|
||||
fl_set_choice(dialog_->choice_style, choice);
|
||||
}
|
||||
|
||||
// Invalid if no citation has been chosen
|
||||
if (fl_get_browser_maxline(dialog_->browser_cite) < 1)
|
||||
activate = ButtonPolicy::SMI_INVALID;
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::update()
|
||||
{
|
||||
// Make the list of all available bibliography keys
|
||||
bibkeys = biblio::getKeys(controller().bibkeysInfo());
|
||||
updateBrowser(dialog_->browser_bib, bibkeys);
|
||||
|
||||
// Ditto for the keys cited in this inset
|
||||
citekeys = getVectorFromString(controller().params().getContents());
|
||||
updateBrowser(dialog_->browser_cite, citekeys);
|
||||
|
||||
// Use the first citekey to fill choice_style
|
||||
string key;
|
||||
if (!citekeys.empty())
|
||||
key = citekeys[0];
|
||||
|
||||
fillChoice(dialog_.get(), controller().getCiteStrings(key));
|
||||
|
||||
// Use the citation command to update the GUI
|
||||
updateStyle(dialog_.get(), controller().params().getCmdName());
|
||||
|
||||
biblio::CiteEngine const engine = controller().getEngine();
|
||||
bool const natbib_engine =
|
||||
engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
|
||||
engine == biblio::ENGINE_NATBIB_NUMERICAL;
|
||||
bool const basic_engine = engine == biblio::ENGINE_BASIC;
|
||||
|
||||
setEnabled(dialog_->check_full_author_list, natbib_engine);
|
||||
setEnabled(dialog_->check_force_uppercase, natbib_engine);
|
||||
setEnabled(dialog_->choice_style, !basic_engine);
|
||||
setEnabled(dialog_->input_before, !basic_engine);
|
||||
|
||||
// No keys have been selected yet, so...
|
||||
fl_clear_browser(dialog_->browser_info);
|
||||
setBibButtons(OFF);
|
||||
setCiteButtons(OFF);
|
||||
|
||||
// Natbib can have comments before and after the citation.
|
||||
fl_set_input(dialog_->input_after,
|
||||
controller().params().getOptions().c_str());
|
||||
|
||||
fl_set_input(dialog_->input_before,
|
||||
controller().params().getSecOptions().c_str());
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::updateBrowser(FL_OBJECT * browser,
|
||||
vector<string> const & keys) const
|
||||
{
|
||||
// Check whether the current contents of the browser will be
|
||||
// changed by loading the contents of the vec...
|
||||
vector<string> browser_keys = getVector(browser);
|
||||
|
||||
if (browser_keys == keys) {
|
||||
fl_deselect_browser(browser);
|
||||
fl_set_browser_topline(browser, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// They will be changed. Proceed.
|
||||
fl_clear_browser(browser);
|
||||
|
||||
for (vector<string>::const_iterator it = keys.begin();
|
||||
it != keys.end(); ++it) {
|
||||
string key = trim(*it);
|
||||
if (!key.empty())
|
||||
fl_add_browser_line(browser, key.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::setBibButtons(State status) const
|
||||
{
|
||||
setEnabled(dialog_->button_add, (status == ON));
|
||||
}
|
||||
|
||||
|
||||
void FormCitation::setCiteButtons(State status) const
|
||||
{
|
||||
int const sel = fl_get_browser(dialog_->browser_cite);
|
||||
int const maxline = fl_get_browser_maxline(dialog_->browser_cite);
|
||||
bool const activate = (status == ON);
|
||||
bool const activate_up = (activate && sel != 1);
|
||||
bool const activate_down = (activate && sel != maxline);
|
||||
|
||||
setEnabled(dialog_->button_del, activate);
|
||||
setEnabled(dialog_->button_up, activate_up);
|
||||
setEnabled(dialog_->button_down, activate_down);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,70 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormCitation.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMCITATION_H
|
||||
#define FORMCITATION_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "biblio.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlCitation;
|
||||
struct FD_citation;
|
||||
|
||||
/** This class provides an XForms implementation of the Citation Dialog.
|
||||
*/
|
||||
class FormCitation
|
||||
: public FormController<ControlCitation, FormView<FD_citation> > {
|
||||
public:
|
||||
///
|
||||
FormCitation(Dialog &);
|
||||
private:
|
||||
///
|
||||
enum State {
|
||||
///
|
||||
ON,
|
||||
///
|
||||
OFF
|
||||
};
|
||||
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/// search for a citation
|
||||
void findBiblio(biblio::Direction const dir);
|
||||
|
||||
///
|
||||
void updateBrowser(FL_OBJECT *, std::vector<std::string> const &) const;
|
||||
///
|
||||
void setBibButtons(State) const;
|
||||
///
|
||||
void setCiteButtons(State) const;
|
||||
|
||||
/// used keys (left panel)
|
||||
std::vector<std::string> citekeys;
|
||||
/// available keys (right panel)
|
||||
std::vector<std::string> bibkeys;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMCITATION_H
|
@ -1,372 +0,0 @@
|
||||
/**
|
||||
* \file FormColorpicker.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormColorpicker.h"
|
||||
#include "forms/form_colorpicker.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_resize.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "support/filetools.h" // LibFileSearch
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using lyx::RGBColor;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
enum GuiColors {
|
||||
GUI_COLOR_CHOICE = FL_FREE_COL13,
|
||||
GUI_COLOR_HUE_DIAL = FL_FREE_COL14,
|
||||
};
|
||||
|
||||
|
||||
string const fillLabel(RGBColor const & rgb)
|
||||
{
|
||||
return convert<string>(rgb.r) + ", " + convert<string>(rgb.g) + ", " + convert<string>(rgb.b);
|
||||
}
|
||||
|
||||
|
||||
string const fillLabel(HSVColor const & hsv)
|
||||
{
|
||||
int const h = int(hsv.h);
|
||||
int const s = int(100.0 * hsv.s);
|
||||
int const v = int(100.0 * hsv.v);
|
||||
|
||||
return convert<string>(h) + ", " + convert<string>(s) + ", " + convert<string>(v);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Callback function invoked by xforms when the dialog is closed by the
|
||||
// window manager.
|
||||
static int C_WMHideCB(FL_FORM * form, void *);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
FormColorpicker::FormColorpicker()
|
||||
: minw_(0), minh_(0),
|
||||
title_(_("Select Color")),
|
||||
finished_(true),
|
||||
icon_pixmap_(0), icon_mask_(0),
|
||||
tooltips_(new Tooltips)
|
||||
{}
|
||||
|
||||
|
||||
FormColorpicker::~FormColorpicker()
|
||||
{
|
||||
if (icon_pixmap_)
|
||||
XFreePixmap(fl_get_display(), icon_pixmap_);
|
||||
}
|
||||
|
||||
|
||||
RGBColor const & FormColorpicker::requestColor(RGBColor const & color)
|
||||
{
|
||||
input_color_ = color;
|
||||
color_ = color;
|
||||
|
||||
show();
|
||||
|
||||
fl_deactivate_all_forms();
|
||||
fl_activate_form(form());
|
||||
|
||||
finished_ = false;
|
||||
while (!finished_)
|
||||
fl_check_forms();
|
||||
|
||||
fl_activate_all_forms();
|
||||
return color_;
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::show()
|
||||
{
|
||||
if (!form()) {
|
||||
build();
|
||||
prepare_to_show();
|
||||
}
|
||||
|
||||
// make sure the form is up to date.
|
||||
fl_freeze_form(form());
|
||||
update();
|
||||
fl_unfreeze_form(form());
|
||||
|
||||
if (form()->visible) {
|
||||
fl_raise_form(form());
|
||||
/* This XMapWindow() will hopefully ensure that
|
||||
* iconified dialogs are de-iconified. Mad props
|
||||
* out to those crazy Xlib guys for forgetting a
|
||||
* XDeiconifyWindow(). At least WindowMaker, when
|
||||
* being notified of the redirected MapRequest will
|
||||
* specifically de-iconify. From source, fvwm2 seems
|
||||
* to do the same.
|
||||
*/
|
||||
XMapWindow(fl_get_display(), form()->window);
|
||||
} else {
|
||||
// calls to fl_set_form_minsize/maxsize apply only to the next
|
||||
// fl_show_form(), so this comes first.
|
||||
fl_set_form_minsize(form(), minw_, minh_);
|
||||
|
||||
string const maximize_title = "LyX: " + title_;
|
||||
int const iconify_policy =
|
||||
lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0;
|
||||
|
||||
fl_show_form(form(),
|
||||
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
||||
iconify_policy,
|
||||
maximize_title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::hide() const
|
||||
{
|
||||
// xforms sometimes tries to process a hint-type MotionNotify, and
|
||||
// use XQueryPointer, without verifying if the window still exists.
|
||||
// So we try to clear out motion events in the queue before the
|
||||
// DestroyNotify
|
||||
XSync(fl_get_display(), false);
|
||||
|
||||
if (form() && form()->visible)
|
||||
fl_hide_form(form());
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::build()
|
||||
{
|
||||
dialog_.reset(build_colorpicker(this));
|
||||
rgb_.reset(build_colorpicker_rgb(this));
|
||||
hsv_.reset(build_colorpicker_hsv(this));
|
||||
|
||||
fl_set_object_color(dialog_->button_color,
|
||||
GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
|
||||
|
||||
fl_set_object_color(hsv_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
|
||||
fl_set_dial_bounds(hsv_->dial_hue, 0.0, 360.0);
|
||||
fl_set_dial_step(hsv_->dial_hue, 1.0);
|
||||
fl_set_dial_return(hsv_->dial_hue, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_slider_bounds(hsv_->slider_saturation, 0.0, 1.0);
|
||||
fl_set_slider_step(hsv_->slider_saturation, 0.01);
|
||||
fl_set_slider_return(hsv_->slider_saturation, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_slider_bounds(hsv_->slider_value, 0.0, 1.0);
|
||||
fl_set_slider_step(hsv_->slider_value, 0.01);
|
||||
fl_set_slider_return(hsv_->slider_value, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_slider_bounds(rgb_->slider_red, 0.0, 255.0);
|
||||
fl_set_slider_step(rgb_->slider_red, 1.0);
|
||||
fl_set_slider_return(rgb_->slider_red, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_slider_bounds(rgb_->slider_green, 0.0, 255.0);
|
||||
fl_set_slider_step(rgb_->slider_green, 1.0);
|
||||
fl_set_slider_return(rgb_->slider_green, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_slider_bounds(rgb_->slider_blue, 0.0, 255.0);
|
||||
fl_set_slider_step(rgb_->slider_blue, 1.0);
|
||||
fl_set_slider_return(rgb_->slider_blue, FL_RETURN_CHANGED);
|
||||
|
||||
// Stack tabs
|
||||
fl_addto_tabfolder(dialog_->tabfolder,_("RGB").c_str(), rgb_->form);
|
||||
fl_addto_tabfolder(dialog_->tabfolder,_("HSV").c_str(), hsv_->form);
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::update() const
|
||||
{
|
||||
fl_mapcolor(GUI_COLOR_CHOICE, color_.r, color_.g, color_.b);
|
||||
|
||||
FL_FORM * folder = fl_get_active_folder(dialog_->tabfolder);
|
||||
|
||||
if (!folder)
|
||||
folder = rgb_->form;
|
||||
|
||||
if (folder == rgb_->form) {
|
||||
fl_set_slider_value(rgb_->slider_red, color_.r);
|
||||
fl_set_slider_value(rgb_->slider_green, color_.g);
|
||||
fl_set_slider_value(rgb_->slider_blue, color_.b);
|
||||
|
||||
fl_set_object_label(dialog_->text_color_values,
|
||||
fillLabel(color_).c_str());
|
||||
|
||||
} else if (folder == hsv_->form) {
|
||||
HSVColor hsv = HSVColor(color_);
|
||||
hsv.h = std::max(hsv.h, 0.0);
|
||||
|
||||
fl_set_dial_value(hsv_->dial_hue, hsv.h);
|
||||
fl_set_slider_value(hsv_->slider_saturation, hsv.s);
|
||||
fl_set_slider_value(hsv_->slider_value, hsv.v);
|
||||
|
||||
fl_set_object_label(dialog_->text_color_values,
|
||||
fillLabel(hsv).c_str());
|
||||
|
||||
RGBColor col = HSVColor(hsv.h, 1.0, 1.0);
|
||||
col.r = std::max(col.r, 0u);
|
||||
fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
|
||||
fl_redraw_object(hsv_->dial_hue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->tabfolder) {
|
||||
update();
|
||||
|
||||
} else if (ob == hsv_->dial_hue ||
|
||||
ob == hsv_->slider_saturation ||
|
||||
ob == hsv_->slider_value) {
|
||||
InputHSV();
|
||||
|
||||
} else if (ob == rgb_->slider_red ||
|
||||
ob == rgb_->slider_green ||
|
||||
ob == rgb_->slider_blue) {
|
||||
InputRGB();
|
||||
|
||||
} else if (ob == dialog_->button_ok) {
|
||||
hide();
|
||||
finished_ = true;
|
||||
|
||||
} else if (ob == dialog_->button_close || ob == 0) {
|
||||
color_ = input_color_;
|
||||
hide();
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FL_FORM * FormColorpicker::form() const
|
||||
{
|
||||
return dialog_.get() ? dialog_->form : 0;
|
||||
}
|
||||
|
||||
|
||||
Tooltips & FormColorpicker::tooltips() const
|
||||
{
|
||||
return *tooltips_;
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::prepare_to_show()
|
||||
{
|
||||
double const scale = get_scale_to_fit(form());
|
||||
if (scale > 1.001)
|
||||
scale_form_horizontally(form(), scale);
|
||||
|
||||
// work around dumb xforms sizing bug
|
||||
minw_ = form()->w;
|
||||
minh_ = form()->h;
|
||||
|
||||
fl_set_form_atclose(form(), C_WMHideCB, 0);
|
||||
|
||||
// set the title for the minimized form
|
||||
if (!lyxrc.dialogs_iconify_with_main)
|
||||
fl_winicontitle(form()->window, title_.c_str());
|
||||
|
||||
// assign an icon to the form
|
||||
string const iconname =
|
||||
support::libFileSearch("images", "lyx", "xpm");
|
||||
|
||||
if (!iconname.empty()) {
|
||||
unsigned int w, h;
|
||||
icon_pixmap_ = fl_read_pixmapfile(fl_root,
|
||||
iconname.c_str(),
|
||||
&w,
|
||||
&h,
|
||||
&icon_mask_,
|
||||
0, 0, 0);
|
||||
fl_set_form_icon(form(), icon_pixmap_, icon_mask_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::InputRGB()
|
||||
{
|
||||
int const red = int(fl_get_slider_value(rgb_->slider_red));
|
||||
int const green = int(fl_get_slider_value(rgb_->slider_green));
|
||||
int const blue = int(fl_get_slider_value(rgb_->slider_blue));
|
||||
|
||||
color_ = RGBColor(red, green, blue);
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
fl_set_object_label(dialog_->text_color_values,
|
||||
fillLabel(color_).c_str());
|
||||
|
||||
fl_mapcolor(GUI_COLOR_CHOICE, color_.r, color_.g, color_.b);
|
||||
fl_redraw_object(dialog_->button_color);
|
||||
|
||||
fl_unfreeze_form(dialog_->form);
|
||||
}
|
||||
|
||||
|
||||
void FormColorpicker::InputHSV()
|
||||
{
|
||||
double const hue = fl_get_dial_value(hsv_->dial_hue);
|
||||
double const sat = fl_get_slider_value(hsv_->slider_saturation);
|
||||
double const val = fl_get_slider_value(hsv_->slider_value);
|
||||
|
||||
HSVColor hsv = HSVColor(hue, sat, val);
|
||||
color_ = hsv;
|
||||
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
fl_set_object_label(dialog_->text_color_values, fillLabel(hsv).c_str());
|
||||
|
||||
fl_mapcolor(GUI_COLOR_CHOICE, color_.r, color_.g, color_.b);
|
||||
fl_redraw_object(dialog_->button_color);
|
||||
|
||||
RGBColor col = HSVColor(hue, 1.0, 1.0);
|
||||
col.r = std::max(col.r, 0u);
|
||||
fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
|
||||
fl_redraw_object(hsv_->dial_hue);
|
||||
|
||||
fl_unfreeze_form(dialog_->form);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void C_FormColorpickerInputCB(FL_OBJECT * ob, long d)
|
||||
{
|
||||
BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
|
||||
FormColorpicker * ptr =
|
||||
static_cast<FormColorpicker *>(ob->form->u_vdata);
|
||||
ptr->input(ob, d);
|
||||
}
|
||||
|
||||
|
||||
static int C_WMHideCB(FL_FORM * form, void *)
|
||||
{
|
||||
// Close the dialog cleanly, even if the WM is used to do so.
|
||||
BOOST_ASSERT(form && form->u_vdata);
|
||||
FormColorpicker * ptr = static_cast<FormColorpicker *>(form->u_vdata);
|
||||
ptr->input(0, 0);
|
||||
return FL_CANCEL;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,91 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormColorpicker.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMCOLORPICKER_H
|
||||
#define FORMCOLORPICKER_H
|
||||
|
||||
#include "Color.h"
|
||||
#include "forms_fwd.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <X11/Xlib.h> // for Pixmap
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class FD_colorpicker;
|
||||
class FD_colorpicker_rgb;
|
||||
class FD_colorpicker_hsv;
|
||||
class Tooltips;
|
||||
|
||||
class FormColorpicker {
|
||||
public:
|
||||
FormColorpicker();
|
||||
~FormColorpicker();
|
||||
|
||||
/** Launch the color picker. All other dialogs are frozen till
|
||||
a color is chosen (or the dialog is closed).
|
||||
\param color the color used to initialise the dialog.
|
||||
*/
|
||||
lyx::RGBColor const & requestColor(lyx::RGBColor const & color);
|
||||
|
||||
/** Input callback function.
|
||||
* Invoked only by the xforms callback interface
|
||||
*/
|
||||
void input(FL_OBJECT *, long);
|
||||
|
||||
private:
|
||||
/// Build the dialog
|
||||
void build();
|
||||
/// Hide the dialog.
|
||||
void hide() const;
|
||||
/// Create the dialog if necessary, update it and display it.
|
||||
void show();
|
||||
/// Update dialog before/whilst showing it.
|
||||
void update() const;
|
||||
|
||||
Tooltips & tooltips() const;
|
||||
/// Pointer to the actual instantiation of xform's form
|
||||
FL_FORM * form() const;
|
||||
|
||||
/** Called on the first show() request, initialising various bits and
|
||||
* pieces.
|
||||
*/
|
||||
void prepare_to_show();
|
||||
|
||||
void InputRGB();
|
||||
void InputHSV();
|
||||
|
||||
/// The dialog's minimum allowable dimensions.
|
||||
int minw_;
|
||||
int minh_;
|
||||
|
||||
/// The title displayed by the Window Manager.
|
||||
std::string title_;
|
||||
|
||||
lyx::RGBColor input_color_;
|
||||
lyx::RGBColor color_;
|
||||
bool finished_;
|
||||
|
||||
/// Passed to the window manager to give a pretty little symbol ;-)
|
||||
Pixmap icon_pixmap_;
|
||||
Pixmap icon_mask_;
|
||||
|
||||
boost::scoped_ptr<Tooltips> tooltips_;
|
||||
boost::scoped_ptr<FD_colorpicker> dialog_;
|
||||
boost::scoped_ptr<FD_colorpicker_rgb> rgb_;
|
||||
boost::scoped_ptr<FD_colorpicker_hsv> hsv_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMCOLORPICKER_H
|
@ -1,423 +0,0 @@
|
||||
/**
|
||||
* \file FormDialogView.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h" // formatted
|
||||
#include "xforms_resize.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/ButtonController.h"
|
||||
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "support/filetools.h" // LibFileSearch
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::bformat;
|
||||
using support::libFileSearch;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
extern "C" {
|
||||
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// These should be in forms.h but aren't
|
||||
void fl_show_tooltip(const char *, int, int);
|
||||
void fl_hide_tooltip();
|
||||
#endif
|
||||
|
||||
// Callback function invoked by xforms when the dialog is closed by the
|
||||
// window manager.
|
||||
static int C_WMHideCB(FL_FORM * form, void *);
|
||||
|
||||
// Callback function invoked by the xforms pre-handler routine.
|
||||
static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
FormDialogView::FormDialogView(Dialog & parent,
|
||||
string const & t, bool allowResize)
|
||||
: Dialog::View(parent, t),
|
||||
warning_posted_(false), message_widget_(0),
|
||||
minw_(0), minh_(0), allow_resize_(allowResize),
|
||||
icon_pixmap_(0), icon_mask_(0),
|
||||
tooltips_(new Tooltips)
|
||||
{}
|
||||
|
||||
|
||||
FormDialogView::~FormDialogView()
|
||||
{
|
||||
if (icon_pixmap_)
|
||||
XFreePixmap(fl_get_display(), icon_pixmap_);
|
||||
|
||||
delete tooltips_;
|
||||
}
|
||||
|
||||
|
||||
bool FormDialogView::isVisible() const
|
||||
{
|
||||
return form() && form()->visible;
|
||||
}
|
||||
|
||||
|
||||
Tooltips & FormDialogView::tooltips()
|
||||
{
|
||||
return *tooltips_;
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::redraw()
|
||||
{
|
||||
if (form() && form()->visible)
|
||||
fl_redraw_form(form());
|
||||
}
|
||||
|
||||
|
||||
xformsBC & FormDialogView::bcview()
|
||||
{
|
||||
return static_cast<xformsBC &>(dialog().bc().view());
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::prepare_to_show()
|
||||
{
|
||||
double const scale = get_scale_to_fit(form());
|
||||
if (scale > 1.001)
|
||||
scale_form_horizontally(form(), scale);
|
||||
|
||||
// work around dumb xforms sizing bug
|
||||
minw_ = form()->w;
|
||||
minh_ = form()->h;
|
||||
|
||||
fl_set_form_atclose(form(), C_WMHideCB, 0);
|
||||
|
||||
// set the title for the minimized form
|
||||
if (!lyxrc.dialogs_iconify_with_main)
|
||||
fl_winicontitle(form()->window, getTitle().c_str());
|
||||
|
||||
// assign an icon to the form
|
||||
string const iconname = libFileSearch("images", "lyx", "xpm");
|
||||
if (!iconname.empty()) {
|
||||
unsigned int w, h;
|
||||
icon_pixmap_ = fl_read_pixmapfile(fl_root,
|
||||
iconname.c_str(),
|
||||
&w,
|
||||
&h,
|
||||
&icon_mask_,
|
||||
0, 0, 0);
|
||||
fl_set_form_icon(form(), icon_pixmap_, icon_mask_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::show()
|
||||
{
|
||||
if (!form()) {
|
||||
build();
|
||||
}
|
||||
|
||||
// we use minw_ to flag whether the dialog has ever been shown.
|
||||
// In turn, prepare_to_show() initialises various bits 'n' pieces
|
||||
// (including minw_).
|
||||
if (minw_ == 0) {
|
||||
prepare_to_show();
|
||||
}
|
||||
|
||||
// make sure the form is up to date.
|
||||
fl_freeze_form(form());
|
||||
update();
|
||||
fl_unfreeze_form(form());
|
||||
if (dialog().controller().exitEarly())
|
||||
return;
|
||||
|
||||
if (form()->visible) {
|
||||
fl_raise_form(form());
|
||||
/* This XMapWindow() will hopefully ensure that
|
||||
* iconified dialogs are de-iconified. Mad props
|
||||
* out to those crazy Xlib guys for forgetting a
|
||||
* XDeiconifyWindow(). At least WindowMaker, when
|
||||
* being notified of the redirected MapRequest will
|
||||
* specifically de-iconify. From source, fvwm2 seems
|
||||
* to do the same.
|
||||
*/
|
||||
XMapWindow(fl_get_display(), form()->window);
|
||||
} else {
|
||||
// calls to fl_set_form_minsize/maxsize apply only to the next
|
||||
// fl_show_form(), so this comes first.
|
||||
fl_set_form_minsize(form(), minw_, minh_);
|
||||
if (!allow_resize_)
|
||||
fl_set_form_maxsize(form(), minw_, minh_);
|
||||
|
||||
string const maximize_title = "LyX: " + getTitle();
|
||||
int const iconify_policy = lyxrc.dialogs_iconify_with_main ?
|
||||
FL_TRANSIENT : 0;
|
||||
|
||||
fl_show_form(form(),
|
||||
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
||||
iconify_policy,
|
||||
maximize_title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::hide()
|
||||
{
|
||||
// xforms sometimes tries to process a hint-type MotionNotify, and
|
||||
// use XQueryPointer, without verifying if the window still exists.
|
||||
// So we try to clear out motion events in the queue before the
|
||||
// DestroyNotify
|
||||
XSync(fl_get_display(), false);
|
||||
|
||||
if (form() && form()->visible)
|
||||
fl_hide_form(form());
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::setPrehandler(FL_OBJECT * ob)
|
||||
{
|
||||
BOOST_ASSERT(ob);
|
||||
fl_set_object_prehandler(ob, C_PrehandlerCB);
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::setMessageWidget(FL_OBJECT * ob)
|
||||
{
|
||||
BOOST_ASSERT(ob && ob->objclass == FL_TEXT);
|
||||
message_widget_ = ob;
|
||||
fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE);
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::InputCB(FL_OBJECT * ob, long data)
|
||||
{
|
||||
// It is possible to set the choice to 0 when using the
|
||||
// keyboard shortcuts. This work-around deals with the problem.
|
||||
if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) {
|
||||
fl_set_choice(ob, 1);
|
||||
}
|
||||
|
||||
bc().input(input(ob, data));
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormDialogView::input(FL_OBJECT *, long)
|
||||
{
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
// preemptive handler for feedback messages
|
||||
void FormDialogView::MessageCB(FL_OBJECT * ob, int event)
|
||||
{
|
||||
BOOST_ASSERT(ob);
|
||||
|
||||
switch (event) {
|
||||
case FL_ENTER:
|
||||
{
|
||||
string const feedback = getFeedback(ob);
|
||||
if (feedback.empty() && warning_posted_)
|
||||
break;
|
||||
|
||||
warning_posted_ = false;
|
||||
postMessage(getFeedback(ob));
|
||||
break;
|
||||
}
|
||||
|
||||
case FL_LEAVE:
|
||||
if (!warning_posted_)
|
||||
clearMessage();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::PrehandlerCB(FL_OBJECT * ob, int event, int key)
|
||||
{
|
||||
BOOST_ASSERT(ob);
|
||||
|
||||
if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) {
|
||||
// Trigger an input event when pasting in an xforms input
|
||||
// object using the middle mouse button.
|
||||
InputCB(ob, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message_widget_) {
|
||||
switch (event) {
|
||||
case FL_ENTER:
|
||||
case FL_LEAVE:
|
||||
// Post feedback as the mouse enters the object,
|
||||
// remove it as the mouse leaves.
|
||||
MessageCB(ob, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
|
||||
// Tooltips are not displayed on browser widgets due to an xforms' bug.
|
||||
// This is a work-around:
|
||||
if (ob->objclass == FL_BROWSER) {
|
||||
switch (event) {
|
||||
case FL_ENTER:
|
||||
if (ob->tooltip && *(ob->tooltip)) {
|
||||
int const x = ob->form->x + ob->x;
|
||||
int const y = ob->form->y + ob->y + ob->h + 1;
|
||||
fl_show_tooltip(ob->tooltip, x, y);
|
||||
}
|
||||
break;
|
||||
case FL_LEAVE:
|
||||
case FL_PUSH:
|
||||
case FL_KEYPRESS:
|
||||
fl_hide_tooltip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::postWarning(string const & warning)
|
||||
{
|
||||
warning_posted_ = true;
|
||||
postMessage(warning);
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::clearMessage()
|
||||
{
|
||||
BOOST_ASSERT(message_widget_);
|
||||
|
||||
warning_posted_ = false;
|
||||
|
||||
string const existing = message_widget_->label
|
||||
? message_widget_->label : string();
|
||||
if (existing.empty())
|
||||
return;
|
||||
|
||||
// This trick is needed to get xforms to clear the label...
|
||||
fl_set_object_label(message_widget_, "");
|
||||
fl_hide_object(message_widget_);
|
||||
}
|
||||
|
||||
|
||||
void FormDialogView::postMessage(string const & message)
|
||||
{
|
||||
BOOST_ASSERT(message_widget_);
|
||||
|
||||
int const width = message_widget_->w - 10;
|
||||
string const tmp = warning_posted_ ?
|
||||
bformat(_("WARNING! %1$s"), message) :
|
||||
message;
|
||||
|
||||
string const str = formatted(tmp, width, FL_NORMAL_SIZE);
|
||||
|
||||
fl_set_object_label(message_widget_, str.c_str());
|
||||
FL_COLOR const label_color = warning_posted_ ? FL_RED : FL_LCOL;
|
||||
fl_set_object_lcol(message_widget_, label_color);
|
||||
|
||||
if (!message_widget_->visible)
|
||||
fl_show_object(message_widget_);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
FormDialogView * GetForm(FL_OBJECT * ob)
|
||||
{
|
||||
BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
|
||||
FormDialogView * ptr =
|
||||
static_cast<FormDialogView *>(ob->form->u_vdata);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void C_FormDialogView_ApplyCB(FL_OBJECT * ob, long)
|
||||
{
|
||||
GetForm(ob)->dialog().ApplyButton();
|
||||
}
|
||||
|
||||
|
||||
void C_FormDialogView_OKCB(FL_OBJECT * ob, long)
|
||||
{
|
||||
GetForm(ob)->dialog().OKButton();
|
||||
}
|
||||
|
||||
|
||||
void C_FormDialogView_CancelCB(FL_OBJECT * ob, long)
|
||||
{
|
||||
FormDialogView * form = GetForm(ob);
|
||||
form->dialog().CancelButton();
|
||||
}
|
||||
|
||||
|
||||
void C_FormDialogView_RestoreCB(FL_OBJECT * ob, long)
|
||||
{
|
||||
GetForm(ob)->dialog().RestoreButton();
|
||||
}
|
||||
|
||||
|
||||
void C_FormDialogView_InputCB(FL_OBJECT * ob, long d)
|
||||
{
|
||||
GetForm(ob)->InputCB(ob, d);
|
||||
}
|
||||
|
||||
|
||||
static int C_WMHideCB(FL_FORM * form, void *)
|
||||
{
|
||||
// Close the dialog cleanly, even if the WM is used to do so.
|
||||
BOOST_ASSERT(form && form->u_vdata);
|
||||
FormDialogView * ptr = static_cast<FormDialogView *>(form->u_vdata);
|
||||
ptr->dialog().CancelButton();
|
||||
return FL_CANCEL;
|
||||
}
|
||||
|
||||
static int C_PrehandlerCB(FL_OBJECT * ob, int event,
|
||||
FL_Coord, FL_Coord, int key, void *)
|
||||
{
|
||||
// Note that the return value is important in the pre-emptive handler.
|
||||
// Don't return anything other than 0.
|
||||
BOOST_ASSERT(ob);
|
||||
|
||||
// Don't Assert this one, as it can happen quite naturally when things
|
||||
// are being deleted in the d-tor.
|
||||
//BOOST_ASSERT(ob->form);
|
||||
if (!ob->form) return 0;
|
||||
|
||||
FormDialogView * ptr =
|
||||
static_cast<FormDialogView *>(ob->form->u_vdata);
|
||||
|
||||
if (ptr)
|
||||
ptr->PrehandlerCB(ob, event, key);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,198 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormDialogView.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
/* A base class for the MCV-ed xforms dialogs.
|
||||
*/
|
||||
|
||||
#ifndef FORMDIALOGVIEW_H
|
||||
#define FORMDIALOGVIEW_H
|
||||
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "ButtonPolicies.h"
|
||||
#include "forms_fwd.h"
|
||||
|
||||
#include <X11/Xlib.h> // for Pixmap
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class Tooltips;
|
||||
class xformsBC;
|
||||
|
||||
/** This class is an XForms GUI base class.
|
||||
*/
|
||||
class FormDialogView : public Dialog::View {
|
||||
public:
|
||||
///
|
||||
FormDialogView(Dialog &, std::string const &, bool allowResize);
|
||||
///
|
||||
virtual ~FormDialogView();
|
||||
|
||||
/** Input callback function.
|
||||
* Invoked only by the xforms callback interface
|
||||
*/
|
||||
void InputCB(FL_OBJECT *, long);
|
||||
|
||||
/** Message callback function.
|
||||
* Invoked only by the xforms callback interface
|
||||
*/
|
||||
void MessageCB(FL_OBJECT *, int event);
|
||||
|
||||
/** Prehandler callback function.
|
||||
* Invoked only by the xforms callback interface
|
||||
*/
|
||||
void PrehandlerCB(FL_OBJECT * ob, int event, int key);
|
||||
|
||||
///
|
||||
Tooltips & tooltips();
|
||||
|
||||
protected:
|
||||
/// Build the dialog
|
||||
virtual void build() = 0;
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Create the dialog if necessary, update it and display it.
|
||||
virtual void show();
|
||||
///
|
||||
virtual bool isVisible() const;
|
||||
|
||||
/** Prepare the way to:
|
||||
* 1. display feedback as the mouse moves over ob. This feedback will
|
||||
* typically be rather more verbose than just a tooltip.
|
||||
* 2. activate the button controller after a paste with the middle
|
||||
* mouse button.
|
||||
*/
|
||||
static void setPrehandler(FL_OBJECT * ob);
|
||||
|
||||
/** Pass the class a pointer to the message_widget so that it can
|
||||
post the message */
|
||||
void setMessageWidget(FL_OBJECT * message_widget);
|
||||
|
||||
/** Send the warning message from the daughter class to the
|
||||
message_widget direct. The message will persist till the mouse
|
||||
movesto a new object. */
|
||||
void postWarning(std::string const & warning);
|
||||
/// Reset the message_widget_
|
||||
void clearMessage();
|
||||
|
||||
///
|
||||
xformsBC & bcview();
|
||||
|
||||
private:
|
||||
/// Pointer to the actual instantiation of xform's form
|
||||
virtual FL_FORM * form() const = 0;
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||
* that the xform colors have been re-mapped).
|
||||
*/
|
||||
virtual void redraw();
|
||||
|
||||
/** Called on the first show() request, initialising various bits and
|
||||
* pieces.
|
||||
*/
|
||||
void prepare_to_show();
|
||||
|
||||
/** Get the feedback message for ob.
|
||||
Called if warning_posted_ == false. */
|
||||
virtual std::string const getFeedback(FL_OBJECT * /* ob */)
|
||||
{ return std::string(); }
|
||||
|
||||
/// Post the feedback message for ob to message_widget_
|
||||
void postMessage(std::string const & message);
|
||||
|
||||
/** Variable used to decide whether to remove the existing feedback
|
||||
message or not (if it is in fact a warning) */
|
||||
bool warning_posted_;
|
||||
/// The widget to display the feedback
|
||||
FL_OBJECT * message_widget_;
|
||||
|
||||
/// The dialog's minimum allowable dimensions.
|
||||
int minw_;
|
||||
///
|
||||
int minh_;
|
||||
/// Can the dialog be resized after it has been created?
|
||||
bool allow_resize_;
|
||||
/// Passed to the window manager to give a pretty little symbol ;-)
|
||||
Pixmap icon_pixmap_;
|
||||
///
|
||||
Pixmap icon_mask_;
|
||||
///
|
||||
Tooltips * tooltips_;
|
||||
};
|
||||
|
||||
|
||||
template <class FL_dialog>
|
||||
class FormView: public FormDialogView {
|
||||
protected:
|
||||
///
|
||||
FormView(Dialog &, std::string const &, bool allowResize=true);
|
||||
/// Pointer to the actual instantiation of xform's form
|
||||
virtual FL_FORM * form() const;
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FL_dialog> dialog_;
|
||||
};
|
||||
|
||||
|
||||
template <class FL_dialog>
|
||||
FormView<FL_dialog>::FormView(Dialog & parent, std::string const & t,
|
||||
bool allowResize)
|
||||
: FormDialogView(parent, t, allowResize)
|
||||
{}
|
||||
|
||||
|
||||
template <class FL_dialog>
|
||||
FL_FORM * FormView<FL_dialog>::form() const
|
||||
{
|
||||
return dialog_.get() ? dialog_->form : 0;
|
||||
}
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
class FormController: public Base {
|
||||
public:
|
||||
/// The parent controller
|
||||
Controller & controller();
|
||||
///
|
||||
Controller const & controller() const;
|
||||
|
||||
protected:
|
||||
///
|
||||
FormController(Dialog &, std::string const &, bool allowResize = true);
|
||||
};
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
FormController<Controller, Base>::FormController(Dialog & p,
|
||||
std::string const & t, bool resize)
|
||||
: Base(p, t, resize)
|
||||
{}
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
Controller & FormController<Controller, Base>::controller()
|
||||
{
|
||||
return static_cast<Controller &>(this->getController());
|
||||
}
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
Controller const & FormController<Controller, Base>::controller() const
|
||||
{
|
||||
return static_cast<Controller const &>(this->getController());
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMDIALOGVIEW_H
|
File diff suppressed because it is too large
Load Diff
@ -1,148 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormDocument.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_DOCUMENT_H
|
||||
#define FORM_DOCUMENT_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "BranchList.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include "lyx_forms.h"
|
||||
#include <vector>
|
||||
|
||||
class BufferParams;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlDocument;
|
||||
class FormColorpicker;
|
||||
struct FD_document;
|
||||
struct FD_document_paper;
|
||||
struct FD_document_font;
|
||||
struct FD_document_class;
|
||||
struct FD_document_language;
|
||||
struct FD_document_options;
|
||||
struct FD_document_bullet;
|
||||
struct FD_document_branch;
|
||||
|
||||
/** This class provides an XForms implementation of the FormDocument dialog.
|
||||
* The table-layout-form here changes values for latex-tabulars
|
||||
*/
|
||||
class FormDocument
|
||||
: public FormController<ControlDocument, FormView<FD_document> > {
|
||||
public:
|
||||
FormDocument(Dialog &);
|
||||
private:
|
||||
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||
that the xforms colours have been re-mapped). */
|
||||
virtual void redraw();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Filter the inputs
|
||||
virtual ButtonPolicy::SMInput input( FL_OBJECT *, long);
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
|
||||
///
|
||||
void branch_input(FL_OBJECT *);
|
||||
///
|
||||
void ChoiceBulletSize(FL_OBJECT * ob, long);
|
||||
///
|
||||
void InputBulletLaTeX(FL_OBJECT * ob, long);
|
||||
///
|
||||
void BulletDepth(FL_OBJECT * ob);
|
||||
///
|
||||
void BulletPanel(FL_OBJECT * ob);
|
||||
///
|
||||
void BulletBMTable(FL_OBJECT * ob, long);
|
||||
///
|
||||
void checkReadOnly();
|
||||
///
|
||||
void CheckChoiceClass();
|
||||
///
|
||||
void UpdateLayoutDocument(BufferParams const & params);
|
||||
///
|
||||
void UpdateClassParams(BufferParams const & params);
|
||||
|
||||
///
|
||||
void paper_update(BufferParams const &);
|
||||
///
|
||||
void class_update(BufferParams const &);
|
||||
///
|
||||
void font_update(BufferParams const &);
|
||||
///
|
||||
void language_update(BufferParams const &);
|
||||
///
|
||||
void options_update(BufferParams const &);
|
||||
///
|
||||
void bullets_update(BufferParams const &);
|
||||
///
|
||||
void branch_update(BufferParams const &);
|
||||
|
||||
///
|
||||
void paper_apply(BufferParams &);
|
||||
///
|
||||
bool class_apply(BufferParams &);
|
||||
///
|
||||
void font_apply(BufferParams &);
|
||||
///
|
||||
bool language_apply(BufferParams &);
|
||||
///
|
||||
void options_apply(BufferParams &);
|
||||
///
|
||||
void bullets_apply(BufferParams &);
|
||||
///
|
||||
void branch_apply(BufferParams &);
|
||||
|
||||
void rebuild_all_branches_browser();
|
||||
void rebuild_selected_branches_browser();
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_document_paper> paper_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_class> class_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_font> font_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_language> language_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_options> options_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_bullet> bullets_;
|
||||
///
|
||||
boost::scoped_ptr<FD_document_branch> branch_;
|
||||
///
|
||||
boost::scoped_ptr<FormColorpicker> picker_;
|
||||
///
|
||||
int ActCell;
|
||||
///
|
||||
int Confirmed;
|
||||
///
|
||||
int current_bullet_panel;
|
||||
///
|
||||
int current_bullet_depth;
|
||||
///
|
||||
FL_OBJECT * fbullet;
|
||||
///
|
||||
std::vector<std::string> lang_;
|
||||
/// Contains all legal branches for this doc
|
||||
BranchList branchlist_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* \file FormERT.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormERT.h"
|
||||
#include "ControlERT.h"
|
||||
#include "forms/form_ert.h"
|
||||
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlERT, FormView<FD_ert> > base_class;
|
||||
|
||||
FormERT::FormERT(Dialog & parent)
|
||||
: base_class(parent, _("TeX Code Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormERT::build()
|
||||
{
|
||||
dialog_.reset(build_ert(this));
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(dialog_->radio_open);
|
||||
bcview().addReadOnly(dialog_->radio_collapsed);
|
||||
bcview().addReadOnly(dialog_->radio_inlined);
|
||||
}
|
||||
|
||||
|
||||
void FormERT::apply()
|
||||
{
|
||||
if (fl_get_button(dialog_->radio_open))
|
||||
controller().setStatus(InsetERT::Open);
|
||||
else if (fl_get_button(dialog_->radio_collapsed))
|
||||
controller().setStatus(InsetERT::Collapsed);
|
||||
else
|
||||
controller().setStatus(InsetERT::Inlined);
|
||||
}
|
||||
|
||||
|
||||
void FormERT::update()
|
||||
{
|
||||
switch (controller().status()) {
|
||||
case InsetERT::Open:
|
||||
fl_set_button(dialog_->radio_open, 1);
|
||||
break;
|
||||
case InsetERT::Collapsed:
|
||||
fl_set_button(dialog_->radio_collapsed, 1);
|
||||
break;
|
||||
case InsetERT::Inlined:
|
||||
fl_set_button(dialog_->radio_inlined, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,42 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormERT.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMERT_H
|
||||
#define FORMERT_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlERT;
|
||||
struct FD_ert;
|
||||
|
||||
/** This class provides an XForms implementation of the ERT
|
||||
Dialog.
|
||||
*/
|
||||
class FormERT : public FormController<ControlERT, FormView<FD_ert> > {
|
||||
public:
|
||||
///
|
||||
FormERT(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMERT_H
|
@ -1,103 +0,0 @@
|
||||
/**
|
||||
* \file FormErrorList.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alfredo Braunstein
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormErrorList.h"
|
||||
#include "ControlErrorList.h"
|
||||
#include "forms/form_errorlist.h"
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "lyx_forms.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
|
||||
|
||||
FormErrorList::FormErrorList(Dialog & parent)
|
||||
: base_class(parent, "")
|
||||
{}
|
||||
|
||||
|
||||
int dumb_validator(FL_OBJECT *, const char *, const char *, int)
|
||||
{
|
||||
return FL_INVALID;
|
||||
}
|
||||
|
||||
|
||||
void FormErrorList::build()
|
||||
{
|
||||
dialog_.reset(build_errorlist(this));
|
||||
fl_set_input_filter(dialog_->input_description, dumb_validator);
|
||||
}
|
||||
|
||||
|
||||
void FormErrorList::update()
|
||||
{
|
||||
setTitle(controller().name());
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->browser_errors) {
|
||||
//xforms return values 1..n
|
||||
int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
|
||||
goTo(choice);
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
void FormErrorList::goTo(int where)
|
||||
{
|
||||
ErrorList const & errors = controller().errorList();
|
||||
|
||||
if (0 <= where && where < int(errors.size())) {
|
||||
controller().goTo(where);
|
||||
fl_set_input(dialog_->input_description,
|
||||
errors[where].description.c_str());
|
||||
fl_set_input_topline(dialog_->input_description, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormErrorList::updateContents()
|
||||
{
|
||||
fl_clear_browser(dialog_->browser_errors);
|
||||
|
||||
ErrorList const & errors = controller().errorList();
|
||||
if (errors.empty()) {
|
||||
fl_add_browser_line(dialog_->browser_errors,
|
||||
_("*** No Lists ***").c_str());
|
||||
setEnabled(dialog_->browser_errors, false);
|
||||
return;
|
||||
}
|
||||
|
||||
setEnabled(dialog_->browser_errors, true);
|
||||
|
||||
ErrorList::const_iterator cit = errors.begin();
|
||||
ErrorList::const_iterator end = errors.end();
|
||||
|
||||
for (; cit != end; ++cit) {
|
||||
fl_add_browser_line(dialog_->browser_errors,
|
||||
cit->error.c_str());
|
||||
}
|
||||
|
||||
fl_select_browser_line(dialog_->browser_errors, 1);
|
||||
goTo(0);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,47 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormErrorList.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alfredo Braunstein
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMERRORLIST_H
|
||||
#define FORMERRORLIST_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlErrorList;
|
||||
struct FD_errorlist;
|
||||
|
||||
/** This class provides an XForms implementation of the FormErrorList Dialog.
|
||||
*/
|
||||
class FormErrorList : public FormController<ControlErrorList, FormView<FD_errorlist> > {
|
||||
public:
|
||||
///
|
||||
FormErrorList(Dialog &);
|
||||
private:
|
||||
/// not needed
|
||||
virtual void apply() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Goto to this error
|
||||
void goTo(int);
|
||||
///
|
||||
void updateContents();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMERRORLIST_H
|
@ -1,761 +0,0 @@
|
||||
/**
|
||||
* \file FormExternal.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Asger Alstrup
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormExternal.h"
|
||||
#include "forms/form_external.h"
|
||||
|
||||
#include "checkedwidgets.h"
|
||||
#include "input_validators.h"
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/ControlExternal.h"
|
||||
|
||||
#include "lengthcommon.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "insets/ExternalTemplate.h"
|
||||
#include "insets/insetexternal.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
namespace external = lyx::external;
|
||||
|
||||
using std::find;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::bformat;
|
||||
using support::float_equal;
|
||||
using support::getStringFromVector;
|
||||
using support::isStrDbl;
|
||||
using support::token;
|
||||
using support::trim;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
LyXLength::UNIT defaultUnit()
|
||||
{
|
||||
LyXLength::UNIT default_unit = LyXLength::CM;
|
||||
switch (lyxrc.default_papersize) {
|
||||
case PAPER_USLETTER:
|
||||
case PAPER_USLEGAL:
|
||||
case PAPER_USEXECUTIVE:
|
||||
default_unit = LyXLength::IN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return default_unit;
|
||||
}
|
||||
|
||||
|
||||
void setDisplay(FL_OBJECT * displayCB, FL_OBJECT * showCO, FL_OBJECT * scaleED,
|
||||
external::DisplayType display, unsigned int scale,
|
||||
bool read_only)
|
||||
{
|
||||
BOOST_ASSERT(displayCB && displayCB->objclass == FL_CHECKBUTTON);
|
||||
BOOST_ASSERT(showCO && showCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(scaleED && scaleED->objclass == FL_INPUT);
|
||||
|
||||
int item = 1;
|
||||
switch (display) {
|
||||
case external::DefaultDisplay:
|
||||
item = 1;
|
||||
break;
|
||||
case external::MonochromeDisplay:
|
||||
item = 2;
|
||||
break;
|
||||
case external::GrayscaleDisplay:
|
||||
item = 3;
|
||||
break;
|
||||
case external::ColorDisplay:
|
||||
item = 4;
|
||||
break;
|
||||
case external::PreviewDisplay:
|
||||
item = 5;
|
||||
break;
|
||||
case external::NoDisplay:
|
||||
item = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
fl_set_choice(showCO, item);
|
||||
|
||||
bool const no_display = display == external::NoDisplay;
|
||||
setEnabled(showCO, !no_display && !read_only);
|
||||
|
||||
fl_set_button(displayCB, !no_display);
|
||||
|
||||
fl_set_input(scaleED, convert<string>(scale).c_str());
|
||||
setEnabled(scaleED, !no_display && !read_only);
|
||||
}
|
||||
|
||||
|
||||
void getDisplay(external::DisplayType & display,
|
||||
unsigned int & scale,
|
||||
FL_OBJECT * displayCB,
|
||||
FL_OBJECT * showCO,
|
||||
FL_OBJECT * scaleED)
|
||||
{
|
||||
BOOST_ASSERT(displayCB && displayCB->objclass == FL_CHECKBUTTON);
|
||||
BOOST_ASSERT(showCO && showCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(scaleED && scaleED->objclass == FL_INPUT);
|
||||
|
||||
switch (fl_get_choice(showCO)) {
|
||||
case 1:
|
||||
display = external::DefaultDisplay;
|
||||
break;
|
||||
case 2:
|
||||
display = external::MonochromeDisplay;
|
||||
break;
|
||||
case 3:
|
||||
display = external::GrayscaleDisplay;
|
||||
break;
|
||||
case 4:
|
||||
display = external::ColorDisplay;
|
||||
break;
|
||||
case 5:
|
||||
display = external::PreviewDisplay;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fl_get_button(displayCB))
|
||||
display = external::NoDisplay;
|
||||
|
||||
scale = convert<int>(getString(scaleED));
|
||||
}
|
||||
|
||||
|
||||
void setRotation(FL_OBJECT * angleED, FL_OBJECT * originCO,
|
||||
external::RotationData const & data)
|
||||
{
|
||||
BOOST_ASSERT(angleED && angleED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(originCO && originCO->objclass == FL_CHOICE);
|
||||
|
||||
fl_set_choice(originCO, 1 + int(data.origin()));
|
||||
fl_set_input(angleED, data.angle.c_str());
|
||||
}
|
||||
|
||||
|
||||
void getRotation(external::RotationData & data,
|
||||
FL_OBJECT * angleED, FL_OBJECT * originCO)
|
||||
{
|
||||
BOOST_ASSERT(angleED && angleED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(originCO && originCO->objclass == FL_CHOICE);
|
||||
|
||||
typedef external::RotationData::OriginType OriginType;
|
||||
|
||||
data.origin(static_cast<OriginType>(fl_get_choice(originCO) - 1));
|
||||
data.angle = getString(angleED);
|
||||
}
|
||||
|
||||
|
||||
void setSize(FL_OBJECT * widthED, FL_OBJECT * widthUnitCO,
|
||||
FL_OBJECT * heightED, FL_OBJECT * heightUnitCO,
|
||||
FL_OBJECT * aspectratioCB,
|
||||
external::ResizeData const & data)
|
||||
{
|
||||
BOOST_ASSERT(widthED && widthED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(widthUnitCO && widthUnitCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(heightED && heightED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(heightUnitCO && heightUnitCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(aspectratioCB &&
|
||||
aspectratioCB->objclass == FL_CHECKBUTTON);
|
||||
|
||||
bool using_scale = data.usingScale();
|
||||
std::string scale = data.scale;
|
||||
if (data.no_resize()) {
|
||||
// Everything is zero, so default to this!
|
||||
using_scale = true;
|
||||
scale = "100";
|
||||
}
|
||||
|
||||
if (using_scale) {
|
||||
fl_set_input(widthED, scale.c_str());
|
||||
fl_set_choice(widthUnitCO, 1);
|
||||
} else {
|
||||
fl_set_input(widthED, convert<string>(data.width.value()).c_str());
|
||||
// Because 'Scale' is position 1...
|
||||
// Note also that width cannot be zero here, so
|
||||
// we don't need to worry about the default unit.
|
||||
fl_set_choice(widthUnitCO, data.width.unit() + 2);
|
||||
}
|
||||
|
||||
string const h = data.height.zero() ? string() : data.height.asString();
|
||||
LyXLength::UNIT default_unit = data.width.zero() ?
|
||||
defaultUnit() : data.width.unit();
|
||||
updateWidgetsFromLengthString(heightED, heightUnitCO,
|
||||
h, stringFromUnit(default_unit));
|
||||
|
||||
setEnabled(heightED, !using_scale);
|
||||
setEnabled(heightUnitCO, !using_scale);
|
||||
|
||||
fl_set_button(aspectratioCB, data.keepAspectRatio);
|
||||
|
||||
bool const disable_aspectRatio = using_scale ||
|
||||
data.width.zero() || data.height.zero();
|
||||
setEnabled(aspectratioCB, !disable_aspectRatio);
|
||||
}
|
||||
|
||||
|
||||
void getSize(external::ResizeData & data,
|
||||
FL_OBJECT * widthED, FL_OBJECT * widthUnitCO,
|
||||
FL_OBJECT * heightED, FL_OBJECT * heightUnitCO,
|
||||
FL_OBJECT * aspectratioCB)
|
||||
{
|
||||
BOOST_ASSERT(widthED && widthED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(widthUnitCO && widthUnitCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(heightED && heightED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(heightUnitCO && heightUnitCO->objclass == FL_CHOICE);
|
||||
BOOST_ASSERT(aspectratioCB &&
|
||||
aspectratioCB->objclass == FL_CHECKBUTTON);
|
||||
|
||||
string const width = getString(widthED);
|
||||
|
||||
if (fl_get_choice(widthUnitCO) > 1) {
|
||||
// Subtract one, because scale is 1.
|
||||
int const unit = fl_get_choice(widthUnitCO) - 1;
|
||||
|
||||
LyXLength w;
|
||||
if (isValidLength(width, &w))
|
||||
data.width = w;
|
||||
else if (isStrDbl(width))
|
||||
data.width = LyXLength(convert<double>(width),
|
||||
static_cast<LyXLength::UNIT>(unit));
|
||||
else
|
||||
data.width = LyXLength();
|
||||
|
||||
data.scale.erase();
|
||||
} else {
|
||||
// scaling instead of a width
|
||||
data.scale = width;
|
||||
data.width = LyXLength();
|
||||
}
|
||||
|
||||
data.height = LyXLength(getLengthFromWidgets(heightED, heightUnitCO));
|
||||
|
||||
data.keepAspectRatio = fl_get_button(aspectratioCB);
|
||||
}
|
||||
|
||||
|
||||
void setCrop(FL_OBJECT * clipCB,
|
||||
FL_OBJECT * xlED, FL_OBJECT * ybED,
|
||||
FL_OBJECT * xrED, FL_OBJECT * ytED,
|
||||
external::ClipData const & data)
|
||||
{
|
||||
BOOST_ASSERT(clipCB && clipCB->objclass == FL_CHECKBUTTON);
|
||||
BOOST_ASSERT(xlED && xlED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(ybED && ybED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(xrED && xrED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(ytED && ytED->objclass == FL_INPUT);
|
||||
|
||||
fl_set_button(clipCB, data.clip);
|
||||
graphics::BoundingBox const & bbox = data.bbox;
|
||||
fl_set_input(xlED, convert<string>(bbox.xl).c_str());
|
||||
fl_set_input(ybED, convert<string>(bbox.yb).c_str());
|
||||
fl_set_input(xrED, convert<string>(bbox.xr).c_str());
|
||||
fl_set_input(ytED, convert<string>(bbox.yt).c_str());
|
||||
}
|
||||
|
||||
|
||||
void getCrop(external::ClipData & data,
|
||||
FL_OBJECT * clipCB,
|
||||
FL_OBJECT * xlED, FL_OBJECT * ybED,
|
||||
FL_OBJECT * xrED, FL_OBJECT * ytED,
|
||||
bool bb_changed)
|
||||
{
|
||||
BOOST_ASSERT(clipCB && clipCB->objclass == FL_CHECKBUTTON);
|
||||
BOOST_ASSERT(xlED && xlED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(ybED && ybED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(xrED && xrED->objclass == FL_INPUT);
|
||||
BOOST_ASSERT(ytED && ytED->objclass == FL_INPUT);
|
||||
|
||||
data.clip = fl_get_button(clipCB);
|
||||
|
||||
if (!bb_changed)
|
||||
return;
|
||||
|
||||
data.bbox.xl = convert<int>(getString(xlED));
|
||||
data.bbox.yb = convert<int>(getString(ybED));
|
||||
data.bbox.xr = convert<int>(getString(xrED));
|
||||
data.bbox.yt = convert<int>(getString(ytED));
|
||||
}
|
||||
|
||||
|
||||
void getExtra(external::ExtraData & data,
|
||||
FormExternal::MapType const & extra)
|
||||
{
|
||||
typedef FormExternal::MapType MapType;
|
||||
MapType::const_iterator it = extra.begin();
|
||||
MapType::const_iterator const end = extra.end();
|
||||
for (; it != end; ++it)
|
||||
data.set(it->first, trim(it->second));
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlExternal, FormView<FD_external> > base_class;
|
||||
|
||||
FormExternal::FormExternal(Dialog & parent)
|
||||
: base_class(parent, _("External Material")),
|
||||
file_checker_(0)
|
||||
{}
|
||||
|
||||
|
||||
void FormExternal::build()
|
||||
{
|
||||
dialog_.reset(build_external(this));
|
||||
file_.reset(build_external_file(this));
|
||||
lyxview_.reset(build_external_lyxview(this));
|
||||
rotate_.reset(build_external_rotate(this));
|
||||
scale_.reset(build_external_scale(this));
|
||||
crop_.reset(build_external_crop(this));
|
||||
options_.reset(build_external_options(this));
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(file_->input_file);
|
||||
bcview().addReadOnly(file_->button_browse);
|
||||
bcview().addReadOnly(file_->button_edit);
|
||||
bcview().addReadOnly(file_->choice_template);
|
||||
bcview().addReadOnly(file_->check_draft);
|
||||
|
||||
bcview().addReadOnly(lyxview_->check_show);
|
||||
bcview().addReadOnly(lyxview_->choice_show);
|
||||
bcview().addReadOnly(lyxview_->input_displayscale);
|
||||
|
||||
bcview().addReadOnly(rotate_->input_angle);
|
||||
bcview().addReadOnly(rotate_->choice_origin);
|
||||
|
||||
bcview().addReadOnly(scale_->input_width);
|
||||
bcview().addReadOnly(scale_->choice_width);
|
||||
bcview().addReadOnly(scale_->input_height);
|
||||
bcview().addReadOnly(scale_->choice_height);
|
||||
bcview().addReadOnly(scale_->check_aspectratio);
|
||||
|
||||
bcview().addReadOnly(crop_->check_bbox);
|
||||
bcview().addReadOnly(crop_->button_get_bbox);
|
||||
bcview().addReadOnly(crop_->input_xr);
|
||||
bcview().addReadOnly(crop_->input_yt);
|
||||
bcview().addReadOnly(crop_->input_xl);
|
||||
bcview().addReadOnly(crop_->input_yb);
|
||||
|
||||
bcview().addReadOnly(options_->choice_option);
|
||||
bcview().addReadOnly(options_->input_option);
|
||||
|
||||
file_checker_ = &addCheckedPath(bcview(), true, file_->input_file);
|
||||
|
||||
// initial setting
|
||||
// addCheckedPositiveFloat(bcview(), scale_->input_width);
|
||||
// As I haven't written addCheckedPositiveFloat, we default to
|
||||
// always checking that it is a valide LyXLength, even when
|
||||
// I'm 'scaling'. No harm done, just not as strict as it might be.
|
||||
addCheckedLyXLength(bcview(), scale_->input_width);
|
||||
addCheckedLyXLength(bcview(), scale_->input_height);
|
||||
|
||||
// addCheckedPositiveFloat(bcview(), input_displayscale);
|
||||
fl_set_input_filter(lyxview_->input_displayscale,
|
||||
fl_unsigned_int_filter);
|
||||
|
||||
fl_set_input_filter(crop_->input_xr, fl_unsigned_int_filter);
|
||||
fl_set_input_filter(crop_->input_yt, fl_unsigned_int_filter);
|
||||
fl_set_input_filter(crop_->input_xl, fl_unsigned_int_filter);
|
||||
fl_set_input_filter(crop_->input_yb, fl_unsigned_int_filter);
|
||||
|
||||
fl_set_input_return(file_->input_file, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(lyxview_->input_displayscale, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(rotate_->input_angle, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(scale_->input_width, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(scale_->input_height, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(crop_->input_xr, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(crop_->input_yt, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(crop_->input_xl, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(crop_->input_yb, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(options_->input_option, FL_RETURN_CHANGED);
|
||||
|
||||
// Trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(file_->input_file);
|
||||
setPrehandler(lyxview_->input_displayscale);
|
||||
setPrehandler(rotate_->input_angle);
|
||||
setPrehandler(scale_->input_width);
|
||||
setPrehandler(scale_->input_height);
|
||||
setPrehandler(crop_->input_xr);
|
||||
setPrehandler(crop_->input_yt);
|
||||
setPrehandler(crop_->input_xl);
|
||||
setPrehandler(crop_->input_yb);
|
||||
setPrehandler(options_->input_option);
|
||||
|
||||
string const choice =
|
||||
' ' + getStringFromVector(controller().getTemplates(), " | ") +
|
||||
' ';
|
||||
fl_addto_choice(file_->choice_template, choice.c_str());
|
||||
|
||||
string const display_list =
|
||||
_("Default|Monochrome|Grayscale|Color|Preview");
|
||||
fl_addto_choice(lyxview_->choice_show, display_list.c_str());
|
||||
|
||||
// Fill the origins combo
|
||||
typedef vector<external::RotationDataType> Origins;
|
||||
Origins const & all_origins = external::all_origins();
|
||||
for (Origins::size_type i = 0; i != all_origins.size(); ++i)
|
||||
fl_addto_choice(rotate_->choice_origin,
|
||||
external::origin_gui_str(i).c_str());
|
||||
|
||||
string const height_list = buildChoiceLengthString();
|
||||
string const width_list = bformat(_("Scale%%%%|%1$s"), height_list);
|
||||
|
||||
fl_addto_choice(scale_->choice_width, width_list.c_str());
|
||||
fl_addto_choice(scale_->choice_height, height_list.c_str());
|
||||
|
||||
// Set up the tooltips.
|
||||
string str = _("The file you want to insert.");
|
||||
tooltips().init(file_->input_file, str);
|
||||
str = _("Browse the directories.");
|
||||
tooltips().init(file_->button_browse, str);
|
||||
|
||||
str = _("Scale the image to inserted percentage value.");
|
||||
tooltips().init(lyxview_->input_displayscale, str);
|
||||
str = _("Select display mode for this image.");
|
||||
tooltips().init(options_->choice_option, str);
|
||||
|
||||
// Stack tabs
|
||||
tabmap_[FILETAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("File").c_str(),
|
||||
file_->form);
|
||||
|
||||
tabmap_[LYXVIEWTAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("LyX View").c_str(),
|
||||
lyxview_->form);
|
||||
tabmap_[ROTATETAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Rotate").c_str(),
|
||||
rotate_->form);
|
||||
tabmap_[SCALETAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Scale").c_str(),
|
||||
scale_->form);
|
||||
tabmap_[CROPTAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Crop").c_str(),
|
||||
crop_->form);
|
||||
tabmap_[OPTIONSTAB] =
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Options").c_str(),
|
||||
options_->form);
|
||||
}
|
||||
|
||||
|
||||
void FormExternal::update()
|
||||
{
|
||||
file_checker_->setChecker(kernel().docType(), lyxrc);
|
||||
|
||||
fl_set_folder_bynumber(dialog_->tabfolder, 1);
|
||||
InsetExternalParams const & params = controller().params();
|
||||
|
||||
string const buffer_path = kernel().bufferFilepath();
|
||||
string const name = params.filename.outputFilename(buffer_path);
|
||||
fl_set_input(file_->input_file, name.c_str());
|
||||
|
||||
int ID = controller().getTemplateNumber(params.templatename());
|
||||
if (ID < 0) ID = 0;
|
||||
fl_set_choice(file_->choice_template, ID+1);
|
||||
|
||||
updateComboChange();
|
||||
|
||||
fl_set_button(file_->check_draft, params.draft);
|
||||
|
||||
setDisplay(lyxview_->check_show, lyxview_->choice_show,
|
||||
lyxview_->input_displayscale,
|
||||
params.display, params.lyxscale,
|
||||
kernel().isBufferReadonly());
|
||||
|
||||
setRotation(rotate_->input_angle, rotate_->choice_origin,
|
||||
params.rotationdata);
|
||||
|
||||
setSize(scale_->input_width, scale_->choice_width,
|
||||
scale_->input_height, scale_->choice_height,
|
||||
scale_->check_aspectratio,
|
||||
params.resizedata);
|
||||
|
||||
setCrop(crop_->check_bbox,
|
||||
crop_->input_xl, crop_->input_yb,
|
||||
crop_->input_xr, crop_->input_yt,
|
||||
params.clipdata);
|
||||
controller().bbChanged(!params.clipdata.bbox.empty());
|
||||
}
|
||||
|
||||
|
||||
void FormExternal::updateComboChange()
|
||||
{
|
||||
int const choice = fl_get_choice(file_->choice_template) - 1;
|
||||
external::Template templ = controller().getTemplate(choice);
|
||||
|
||||
// Update the help text
|
||||
string const txt = formatted(templ.helpText,
|
||||
file_->browser_template->w - 20);
|
||||
fl_clear_browser(file_->browser_template);
|
||||
fl_addto_browser(file_->browser_template, txt.c_str());
|
||||
fl_set_browser_topline(file_->browser_template, 0);
|
||||
|
||||
// Ascertain which (if any) transformations the template supports
|
||||
// and disable tabs hosting unsupported transforms.
|
||||
typedef vector<external::TransformID> TransformIDs;
|
||||
TransformIDs const transformIds = templ.transformIds;
|
||||
TransformIDs::const_iterator tr_begin = transformIds.begin();
|
||||
TransformIDs::const_iterator const tr_end = transformIds.end();
|
||||
|
||||
tabmap_[FILETAB];
|
||||
tabmap_[LYXVIEWTAB];
|
||||
tabmap_[ROTATETAB];
|
||||
tabmap_[SCALETAB];
|
||||
tabmap_[CROPTAB];
|
||||
tabmap_[OPTIONSTAB];
|
||||
|
||||
bool found = find(tr_begin, tr_end, external::Rotate) != tr_end;
|
||||
setEnabled(tabmap_[ROTATETAB], found);
|
||||
|
||||
found = find(tr_begin, tr_end, external::Resize) != tr_end;
|
||||
setEnabled(tabmap_[SCALETAB], found);
|
||||
|
||||
found = find(tr_begin, tr_end, external::Clip) != tr_end;
|
||||
setEnabled(tabmap_[CROPTAB], found);
|
||||
|
||||
found = find(tr_begin, tr_end, external::Extra) != tr_end;
|
||||
setEnabled(tabmap_[OPTIONSTAB], found);
|
||||
|
||||
if (!found)
|
||||
return;
|
||||
|
||||
// Ascertain whether the template has any formats supporting
|
||||
// the 'Extra' option
|
||||
FL_OBJECT * const ob_input = options_->input_option;
|
||||
FL_OBJECT * const ob_choice = options_->choice_option;
|
||||
extra_.clear();
|
||||
fl_set_input(ob_input, "");
|
||||
fl_clear_choice(ob_choice);
|
||||
|
||||
external::Template::Formats::const_iterator it = templ.formats.begin();
|
||||
external::Template::Formats::const_iterator end = templ.formats.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->second.option_transformers.find(external::Extra) ==
|
||||
it->second.option_transformers.end())
|
||||
continue;
|
||||
string const format = it->first;
|
||||
string const opt = controller().params().extradata.get(format);
|
||||
fl_addto_choice(ob_choice, format.c_str());
|
||||
extra_[format] = opt;
|
||||
}
|
||||
|
||||
bool const enabled = fl_get_choice_maxitems(ob_choice) > 0;
|
||||
|
||||
setEnabled(tabmap_[OPTIONSTAB], enabled);
|
||||
setEnabled(ob_input, enabled && !kernel().isBufferReadonly());
|
||||
setEnabled(ob_choice, enabled);
|
||||
|
||||
if (enabled) {
|
||||
fl_set_choice(ob_choice, 1);
|
||||
string const format = fl_get_choice_text(ob_choice);
|
||||
fl_set_input(ob_input, extra_[format].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormExternal::apply()
|
||||
{
|
||||
InsetExternalParams params = controller().params();
|
||||
|
||||
string const buffer_path = kernel().bufferFilepath();
|
||||
params.filename.set(getString(file_->input_file), buffer_path);
|
||||
|
||||
int const choice = fl_get_choice(file_->choice_template) - 1;
|
||||
params.settemplate(controller().getTemplate(choice).lyxName);
|
||||
|
||||
params.draft = fl_get_button(file_->check_draft);
|
||||
|
||||
getDisplay(params.display, params.lyxscale,
|
||||
lyxview_->check_show, lyxview_->choice_show,
|
||||
lyxview_->input_displayscale);
|
||||
|
||||
if (isActive(tabmap_[ROTATETAB]))
|
||||
getRotation(params.rotationdata,
|
||||
rotate_->input_angle, rotate_->choice_origin);
|
||||
|
||||
if (isActive(tabmap_[SCALETAB]))
|
||||
getSize(params.resizedata,
|
||||
scale_->input_width, scale_->choice_width,
|
||||
scale_->input_height, scale_->choice_height,
|
||||
scale_->check_aspectratio);
|
||||
|
||||
if (isActive(tabmap_[CROPTAB]))
|
||||
getCrop(params.clipdata,
|
||||
crop_->check_bbox,
|
||||
crop_->input_xl, crop_->input_yb,
|
||||
crop_->input_xr, crop_->input_yt,
|
||||
controller().bbChanged());
|
||||
|
||||
if (isActive(tabmap_[OPTIONSTAB]))
|
||||
getExtra(params.extradata, extra_);
|
||||
|
||||
controller().setParams(params);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
ButtonPolicy::SMInput result = ButtonPolicy::SMI_VALID;
|
||||
|
||||
if (ob == file_->choice_template) {
|
||||
|
||||
// set to the chosen template
|
||||
updateComboChange();
|
||||
|
||||
} else if (ob == file_->button_browse) {
|
||||
|
||||
string const in_name = fl_get_input(file_->input_file);
|
||||
|
||||
int const choice = fl_get_choice(file_->choice_template) - 1;
|
||||
string const template_name =
|
||||
controller().getTemplate(choice).lyxName;
|
||||
string const out_name =
|
||||
controller().browse(in_name, template_name);
|
||||
fl_set_input(file_->input_file, out_name.c_str());
|
||||
|
||||
} else if (ob == file_->button_edit) {
|
||||
controller().editExternal();
|
||||
result = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
} else if (ob == lyxview_->check_show) {
|
||||
|
||||
bool const checked = fl_get_button(ob);
|
||||
setEnabled(lyxview_->choice_show, checked);
|
||||
setEnabled(lyxview_->input_displayscale, checked);
|
||||
|
||||
} else if (ob == crop_->button_get_bbox) {
|
||||
|
||||
getBB();
|
||||
|
||||
} else if (ob == scale_->input_width ||
|
||||
ob == scale_->input_height) {
|
||||
|
||||
setEnabled(scale_->check_aspectratio,
|
||||
activateAspectratio());
|
||||
|
||||
} else if (ob == scale_->choice_width) {
|
||||
|
||||
widthUnitChanged();
|
||||
|
||||
} else if (ob == crop_->input_xr ||
|
||||
ob == crop_->input_yt ||
|
||||
ob == crop_->input_xl ||
|
||||
ob == crop_->input_yb) {
|
||||
|
||||
controller().bbChanged(true);
|
||||
|
||||
} else if (ob == options_->input_option) {
|
||||
|
||||
string const format =
|
||||
fl_get_choice_text(options_->choice_option);
|
||||
extra_[format] = getString(options_->input_option);
|
||||
|
||||
} else if (ob == options_->choice_option) {
|
||||
|
||||
string const format =
|
||||
fl_get_choice_text(options_->choice_option);
|
||||
fl_set_input(options_->input_option, extra_[format].c_str());
|
||||
result = ButtonPolicy::SMI_NOOP;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool FormExternal::activateAspectratio() const
|
||||
{
|
||||
if (fl_get_choice(scale_->choice_width) == 1)
|
||||
return false;
|
||||
|
||||
string const wstr = getString(scale_->input_width);
|
||||
if (wstr.empty())
|
||||
return false;
|
||||
bool const wIsDbl = isStrDbl(wstr);
|
||||
if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
|
||||
return false;
|
||||
LyXLength l;
|
||||
if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
|
||||
return false;
|
||||
|
||||
string const hstr = getString(scale_->input_height);
|
||||
if (hstr.empty())
|
||||
return false;
|
||||
bool const hIsDbl = isStrDbl(hstr);
|
||||
if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
|
||||
return false;
|
||||
if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FormExternal::getBB()
|
||||
{
|
||||
fl_set_input(crop_->input_xl, "0");
|
||||
fl_set_input(crop_->input_yb, "0");
|
||||
fl_set_input(crop_->input_xr, "0");
|
||||
fl_set_input(crop_->input_yt, "0");
|
||||
|
||||
string const filename = getString(file_->input_file);
|
||||
if (filename.empty())
|
||||
return;
|
||||
|
||||
string const bb = controller().readBB(filename);
|
||||
if (bb.empty())
|
||||
return;
|
||||
|
||||
fl_set_input(crop_->input_xl, token(bb, ' ', 0).c_str());
|
||||
fl_set_input(crop_->input_yb, token(bb, ' ', 1).c_str());
|
||||
fl_set_input(crop_->input_xr, token(bb, ' ', 2).c_str());
|
||||
fl_set_input(crop_->input_yt, token(bb, ' ', 3).c_str());
|
||||
|
||||
controller().bbChanged(false);
|
||||
}
|
||||
|
||||
|
||||
void FormExternal::widthUnitChanged()
|
||||
{
|
||||
if (fl_get_choice(scale_->choice_width) == 1)
|
||||
return;
|
||||
|
||||
bool useHeight = fl_get_choice(scale_->choice_width) > 1;
|
||||
|
||||
// if (useHeight)
|
||||
// widthED->setValidator(unsignedLengthValidator(widthED));
|
||||
// else
|
||||
// widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
|
||||
|
||||
setEnabled(scale_->input_height, useHeight);
|
||||
setEnabled(scale_->choice_height, useHeight);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,90 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormExternal.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Asger Alstrup Nielsen
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMEXTERNAL_H
|
||||
#define FORMEXTERNAL_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include <map>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class CheckedPath;
|
||||
class ControlExternal;
|
||||
struct FD_external;
|
||||
struct FD_external_file;
|
||||
struct FD_external_lyxview;
|
||||
struct FD_external_rotate;
|
||||
struct FD_external_scale;
|
||||
struct FD_external_crop;
|
||||
struct FD_external_options;
|
||||
|
||||
/// The class for editing External insets via a dialog
|
||||
class FormExternal
|
||||
: public FormController<ControlExternal, FormView<FD_external> > {
|
||||
public:
|
||||
///
|
||||
FormExternal(Dialog &);
|
||||
|
||||
typedef std::map<std::string, std::string> MapType;
|
||||
|
||||
enum Tabs {
|
||||
FILETAB,
|
||||
LYXVIEWTAB,
|
||||
ROTATETAB,
|
||||
SCALETAB,
|
||||
CROPTAB,
|
||||
OPTIONSTAB
|
||||
};
|
||||
|
||||
typedef std::map<Tabs, FL_OBJECT *> TabMap;
|
||||
|
||||
private:
|
||||
/// apply changes
|
||||
virtual void apply();
|
||||
|
||||
/// build the dialog
|
||||
virtual void build();
|
||||
|
||||
/// update the dialog
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
bool activateAspectratio() const;
|
||||
void getBB();
|
||||
void updateComboChange();
|
||||
void widthUnitChanged();
|
||||
|
||||
// Accessor to checker owned by the button controller.
|
||||
CheckedPath * file_checker_;
|
||||
|
||||
MapType extra_;
|
||||
|
||||
TabMap tabmap_;
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_external_file> file_;
|
||||
boost::scoped_ptr<FD_external_lyxview> lyxview_;
|
||||
boost::scoped_ptr<FD_external_rotate> rotate_;
|
||||
boost::scoped_ptr<FD_external_scale> scale_;
|
||||
boost::scoped_ptr<FD_external_crop> crop_;
|
||||
boost::scoped_ptr<FD_external_options> options_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMEXTERNAL_H
|
@ -1,708 +0,0 @@
|
||||
/**
|
||||
* \file FormFiledialog.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormFiledialog.h"
|
||||
#include "forms/form_filedialog.h"
|
||||
|
||||
#include "forms_gettext.h"
|
||||
#include "globbing.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#include "support/filefilterlist.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/package.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
using lyx::support::absolutePath;
|
||||
using lyx::support::addName;
|
||||
using lyx::support::expandPath;
|
||||
using lyx::support::FileFilterList;
|
||||
using lyx::support::getcwd;
|
||||
using lyx::support::makeAbsPath;
|
||||
using lyx::support::onlyFilename;
|
||||
using lyx::support::package;
|
||||
using lyx::support::split;
|
||||
using lyx::support::suffixIs;
|
||||
using lyx::support::trim;
|
||||
|
||||
using std::max;
|
||||
using std::sort;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using namespace lyx::frontend;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
/** Given a string "<glob> <glob> <glob>", expand each glob in turn.
|
||||
* Any glob that cannot be expanded is ignored silently.
|
||||
* Invokes \c convert_brace_glob and \c glob internally, so use only
|
||||
* on systems supporting the Posix function 'glob'.
|
||||
* \param mask the string "<glob> <glob> <glob>".
|
||||
* \param directory the current working directory from
|
||||
* which \c glob is invoked.
|
||||
* \returns a vector of all matching file names.
|
||||
*/
|
||||
vector<string> const expand_globs(string const & mask,
|
||||
string const & directory)
|
||||
{
|
||||
// Split into individual globs and then call 'glob' on each one.
|
||||
typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
|
||||
boost::char_separator<char> const separator(" ");
|
||||
|
||||
vector<string> matches;
|
||||
Tokenizer const tokens(mask, separator);
|
||||
Tokenizer::const_iterator it = tokens.begin();
|
||||
Tokenizer::const_iterator const end = tokens.end();
|
||||
for (; it != end; ++it)
|
||||
lyx::support::glob(matches, *it, directory);
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
static
|
||||
int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev)
|
||||
{
|
||||
return FileDialog::Private::CancelCB(fl, xev);
|
||||
}
|
||||
|
||||
static
|
||||
void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
|
||||
{
|
||||
FileDialog::Private::DoubleClickCB(ob, data);
|
||||
}
|
||||
|
||||
static
|
||||
void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data)
|
||||
{
|
||||
FileDialog::Private::FileDlgCB(ob, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// compares two LyXDirEntry objects content (used for sort)
|
||||
class comp_direntry : public std::binary_function<DirEntry, DirEntry, bool> {
|
||||
public:
|
||||
bool operator()(DirEntry const & r1, DirEntry const & r2) const
|
||||
{
|
||||
bool const r1d = suffixIs(r1.name_, '/');
|
||||
bool const r2d = suffixIs(r2.name_, '/');
|
||||
if (r1d && !r2d)
|
||||
return true;
|
||||
if (!r1d && r2d)
|
||||
return false;
|
||||
return r1.name_ < r2.name_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
// *** FileDialog::Private class implementation
|
||||
|
||||
// static members
|
||||
FD_filedialog * FileDialog::Private::file_dlg_form_ = 0;
|
||||
FileDialog::Private * FileDialog::Private::current_dlg_ = 0;
|
||||
int FileDialog::Private::minw_ = 0;
|
||||
int FileDialog::Private::minh_ = 0;
|
||||
|
||||
|
||||
// Reread: updates dialog list to match class directory
|
||||
void FileDialog::Private::Reread()
|
||||
{
|
||||
// Opens directory
|
||||
if (!fs::exists(directory_) || !fs::is_directory(directory_)) {
|
||||
// FIXME: re-add ...
|
||||
#if 0
|
||||
Alert::err_alert(_("Warning! Couldn't open directory."),
|
||||
directory_);
|
||||
#endif
|
||||
directory_ = getcwd();
|
||||
}
|
||||
|
||||
// Clear the present namelist
|
||||
dir_entries_.clear();
|
||||
|
||||
// Updates display
|
||||
fl_hide_object(file_dlg_form_->List);
|
||||
fl_clear_browser(file_dlg_form_->List);
|
||||
fl_set_input(file_dlg_form_->DirBox, directory_.c_str());
|
||||
|
||||
// Splits complete directory name into directories and compute depth
|
||||
depth_ = 0;
|
||||
string line;
|
||||
string Temp;
|
||||
string File = directory_;
|
||||
if (File != "/")
|
||||
File = split(File, Temp, '/');
|
||||
|
||||
while (!File.empty() || !Temp.empty()) {
|
||||
string const dline = "@b" + line + Temp + '/';
|
||||
fl_add_browser_line(file_dlg_form_->List, dline.c_str());
|
||||
File = split(File, Temp, '/');
|
||||
line += ' ';
|
||||
++depth_;
|
||||
}
|
||||
|
||||
vector<string> const glob_matches = expand_globs(mask_, directory_);
|
||||
|
||||
fs::directory_iterator beg(directory_);
|
||||
fs::directory_iterator end;
|
||||
for (; beg != end; ++beg) {
|
||||
string const fname = beg->leaf();
|
||||
|
||||
// If the pattern doesn't start with a dot, skip hidden files
|
||||
if (!mask_.empty() && mask_[0] != '.' && fname[0] == '.')
|
||||
continue;
|
||||
|
||||
bool const isDir = fs::exists(*beg) && fs::is_directory(*beg);
|
||||
|
||||
// filters files according to pattern and type
|
||||
typedef vector<string>::const_iterator viterator;
|
||||
viterator gbegin = glob_matches.begin();
|
||||
viterator const gend = glob_matches.end();
|
||||
|
||||
if (!isDir && std::find(gbegin, gend, fname) == gend)
|
||||
continue;
|
||||
|
||||
DirEntry tmp;
|
||||
// creates used name
|
||||
tmp.name_ = fname;
|
||||
|
||||
if (isDir)
|
||||
tmp.name_ += '/';
|
||||
|
||||
// creates displayed name
|
||||
tmp.displayed_ = fname;
|
||||
dir_entries_.push_back(tmp);
|
||||
}
|
||||
|
||||
// Sort the names
|
||||
sort(dir_entries_.begin(), dir_entries_.end(), comp_direntry());
|
||||
|
||||
// Add them to directory box
|
||||
for (DirEntries::const_iterator cit = dir_entries_.begin();
|
||||
cit != dir_entries_.end(); ++cit) {
|
||||
string const temp = line + cit->displayed_;
|
||||
fl_add_browser_line(file_dlg_form_->List, temp.c_str());
|
||||
}
|
||||
fl_set_browser_topline(file_dlg_form_->List, depth_);
|
||||
fl_show_object(file_dlg_form_->List);
|
||||
last_sel_ = -1;
|
||||
}
|
||||
|
||||
|
||||
// SetDirectory: sets dialog current directory
|
||||
void FileDialog::Private::SetDirectory(string const & path)
|
||||
{
|
||||
string tmp;
|
||||
if (path.empty())
|
||||
tmp = getcwd();
|
||||
else
|
||||
tmp = makeAbsPath(expandPath(path), directory_);
|
||||
|
||||
// must check the directory exists
|
||||
if (!fs::exists(tmp) || !fs::is_directory(tmp)) {
|
||||
// FIXME: re-add ...
|
||||
#if 0
|
||||
Alert::err_alert(_("Warning! Couldn't open directory."), tmp);
|
||||
#endif
|
||||
} else {
|
||||
directory_ = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileDialog::Private::SetFilters(string const & mask)
|
||||
{
|
||||
SetFilters(FileFilterList(mask));
|
||||
}
|
||||
|
||||
|
||||
void FileDialog::Private::SetFilters(FileFilterList const & filters)
|
||||
{
|
||||
if (filters.empty())
|
||||
return;
|
||||
|
||||
// Just take the first one for now.
|
||||
typedef FileFilterList::Filter::glob_iterator glob_iterator;
|
||||
glob_iterator const begin = filters[0].begin();
|
||||
glob_iterator const end = filters[0].end();
|
||||
if (begin == end)
|
||||
return;
|
||||
|
||||
ostringstream ss;
|
||||
for (glob_iterator it = begin; it != end; ++it) {
|
||||
if (it != begin)
|
||||
ss << ' ';
|
||||
ss << *it;
|
||||
}
|
||||
|
||||
mask_ = ss.str();
|
||||
fl_set_input(file_dlg_form_->PatBox, mask_.c_str());
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Private::Private()
|
||||
{
|
||||
directory_ = makeAbsPath(string("."));
|
||||
|
||||
// Creates form if necessary.
|
||||
if (!file_dlg_form_) {
|
||||
file_dlg_form_ = build_filedialog(this);
|
||||
minw_ = file_dlg_form_->form->w;
|
||||
minh_ = file_dlg_form_->form->h;
|
||||
// Set callbacks. This means that we don't need a patch file
|
||||
fl_set_object_callback(file_dlg_form_->DirBox,
|
||||
C_LyXFileDlg_FileDlgCB, 0);
|
||||
fl_set_object_callback(file_dlg_form_->PatBox,
|
||||
C_LyXFileDlg_FileDlgCB, 1);
|
||||
fl_set_object_callback(file_dlg_form_->List,
|
||||
C_LyXFileDlg_FileDlgCB, 2);
|
||||
fl_set_object_callback(file_dlg_form_->Filename,
|
||||
C_LyXFileDlg_FileDlgCB, 3);
|
||||
fl_set_object_callback(file_dlg_form_->Rescan,
|
||||
C_LyXFileDlg_FileDlgCB, 10);
|
||||
fl_set_object_callback(file_dlg_form_->Home,
|
||||
C_LyXFileDlg_FileDlgCB, 11);
|
||||
fl_set_object_callback(file_dlg_form_->User1,
|
||||
C_LyXFileDlg_FileDlgCB, 12);
|
||||
fl_set_object_callback(file_dlg_form_->User2,
|
||||
C_LyXFileDlg_FileDlgCB, 13);
|
||||
|
||||
// Make sure pressing the close box doesn't crash LyX. (RvdK)
|
||||
fl_set_form_atclose(file_dlg_form_->form,
|
||||
C_LyXFileDlg_CancelCB, 0);
|
||||
// Register doubleclick callback
|
||||
fl_set_browser_dblclick_callback(file_dlg_form_->List,
|
||||
C_LyXFileDlg_DoubleClickCB,
|
||||
0);
|
||||
}
|
||||
fl_hide_object(file_dlg_form_->User1);
|
||||
fl_hide_object(file_dlg_form_->User2);
|
||||
|
||||
r_ = Dialogs::redrawGUI().connect(boost::bind(&FileDialog::Private::redraw, this));
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Private::~Private()
|
||||
{
|
||||
r_.disconnect();
|
||||
}
|
||||
|
||||
|
||||
void FileDialog::Private::redraw()
|
||||
{
|
||||
if (file_dlg_form_->form && file_dlg_form_->form->visible)
|
||||
fl_redraw_form(file_dlg_form_->form);
|
||||
}
|
||||
|
||||
|
||||
// SetButton: sets file selector user button action
|
||||
void FileDialog::Private::SetButton(int index, string const & name,
|
||||
string const & path)
|
||||
{
|
||||
FL_OBJECT * ob;
|
||||
string * tmp;
|
||||
|
||||
if (index == 0) {
|
||||
ob = file_dlg_form_->User1;
|
||||
tmp = &user_path1_;
|
||||
} else if (index == 1) {
|
||||
ob = file_dlg_form_->User2;
|
||||
tmp = &user_path2_;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!name.empty()) {
|
||||
fl_set_object_label(ob, idex(name).c_str());
|
||||
fl_set_button_shortcut(ob, scex(name).c_str(), 1);
|
||||
fl_show_object(ob);
|
||||
*tmp = path;
|
||||
} else {
|
||||
fl_hide_object(ob);
|
||||
tmp->erase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// GetDirectory: gets last dialog directory
|
||||
string const FileDialog::Private::GetDirectory() const
|
||||
{
|
||||
if (!directory_.empty())
|
||||
return directory_;
|
||||
else
|
||||
return string(".");
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool x_sync_kludge(bool ret)
|
||||
{
|
||||
XSync(fl_get_display(), false);
|
||||
return ret;
|
||||
}
|
||||
} // namespace anon
|
||||
|
||||
// RunDialog: handle dialog during file selection
|
||||
bool FileDialog::Private::RunDialog()
|
||||
{
|
||||
force_cancel_ = false;
|
||||
force_ok_ = false;
|
||||
|
||||
// event loop
|
||||
while (true) {
|
||||
FL_OBJECT * ob = fl_do_forms();
|
||||
|
||||
if (ob == file_dlg_form_->Ready) {
|
||||
if (HandleOK())
|
||||
return x_sync_kludge(true);
|
||||
|
||||
} else if (ob == file_dlg_form_->Cancel || force_cancel_)
|
||||
return x_sync_kludge(false);
|
||||
|
||||
else if (force_ok_)
|
||||
return x_sync_kludge(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XForms objects callback (static)
|
||||
void FileDialog::Private::FileDlgCB(FL_OBJECT *, long arg)
|
||||
{
|
||||
if (!current_dlg_)
|
||||
return;
|
||||
|
||||
switch (arg) {
|
||||
|
||||
case 0: // get directory
|
||||
current_dlg_->SetDirectory(fl_get_input(file_dlg_form_->DirBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
case 1: // get mask
|
||||
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
case 2: // list
|
||||
current_dlg_->HandleListHit();
|
||||
break;
|
||||
|
||||
case 10: // rescan
|
||||
current_dlg_->SetDirectory(fl_get_input(file_dlg_form_->DirBox));
|
||||
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
case 11: // home
|
||||
current_dlg_->SetDirectory(package().home_dir());
|
||||
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
case 12: // user button 1
|
||||
current_dlg_->SetDirectory(current_dlg_->user_path1_);
|
||||
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
case 13: // user button 2
|
||||
current_dlg_->SetDirectory(current_dlg_->user_path2_);
|
||||
current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
|
||||
current_dlg_->Reread();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle callback from list
|
||||
void FileDialog::Private::HandleListHit()
|
||||
{
|
||||
// set info line
|
||||
int const select_ = fl_get_browser(file_dlg_form_->List);
|
||||
string line = (select_ > depth_ ?
|
||||
dir_entries_[select_ - depth_ - 1].name_ :
|
||||
string());
|
||||
if (suffixIs(line, '/'))
|
||||
line.clear();
|
||||
fl_set_input(file_dlg_form_->Filename, line.c_str());
|
||||
}
|
||||
|
||||
|
||||
// Callback for double click in list
|
||||
void FileDialog::Private::DoubleClickCB(FL_OBJECT *, long)
|
||||
{
|
||||
// Simulate click on OK button
|
||||
if (current_dlg_->HandleDoubleClick())
|
||||
current_dlg_->Force(false);
|
||||
}
|
||||
|
||||
|
||||
// Handle double click from list
|
||||
bool FileDialog::Private::HandleDoubleClick()
|
||||
{
|
||||
string tmp;
|
||||
|
||||
// set info line
|
||||
bool isDir = true;
|
||||
int const select_ = fl_get_browser(file_dlg_form_->List);
|
||||
if (select_ > depth_) {
|
||||
tmp = dir_entries_[select_ - depth_ - 1].name_;
|
||||
if (!suffixIs(tmp, '/')) {
|
||||
isDir = false;
|
||||
fl_set_input(file_dlg_form_->Filename, tmp.c_str());
|
||||
}
|
||||
} else if (select_ == 0)
|
||||
return true;
|
||||
|
||||
// executes action
|
||||
if (isDir) {
|
||||
string Temp;
|
||||
|
||||
// builds new directory name
|
||||
if (select_ > depth_) {
|
||||
// Directory deeper down
|
||||
// First, get directory with trailing /
|
||||
Temp = fl_get_input(file_dlg_form_->DirBox);
|
||||
if (!suffixIs(Temp, '/'))
|
||||
Temp += '/';
|
||||
Temp += tmp;
|
||||
} else {
|
||||
// Directory higher up
|
||||
Temp.erase();
|
||||
for (int i = 0; i < select_; ++i) {
|
||||
string const piece = fl_get_browser_line(file_dlg_form_->List, i + 1);
|
||||
// The '+2' is here to count the '@b' (JMarc)
|
||||
Temp += piece.substr(i + 2);
|
||||
}
|
||||
}
|
||||
|
||||
// assigns it
|
||||
SetDirectory(Temp);
|
||||
Reread();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Handle OK button call
|
||||
bool FileDialog::Private::HandleOK()
|
||||
{
|
||||
// mask was changed
|
||||
string tmp = fl_get_input(file_dlg_form_->PatBox);
|
||||
if (tmp != mask_) {
|
||||
SetFilters(tmp);
|
||||
Reread();
|
||||
return false;
|
||||
}
|
||||
|
||||
// directory was changed
|
||||
tmp = fl_get_input(file_dlg_form_->DirBox);
|
||||
if (tmp != directory_) {
|
||||
SetDirectory(tmp);
|
||||
Reread();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handle return from list
|
||||
int const select = fl_get_browser(file_dlg_form_->List);
|
||||
if (select > depth_) {
|
||||
string const temp = dir_entries_[select - depth_ - 1].name_;
|
||||
if (!suffixIs(temp, '/')) {
|
||||
// If user didn't type anything, use browser
|
||||
string const name = fl_get_input(file_dlg_form_->Filename);
|
||||
if (name.empty())
|
||||
fl_set_input(file_dlg_form_->Filename, temp.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Emulate a doubleclick
|
||||
return HandleDoubleClick();
|
||||
}
|
||||
|
||||
|
||||
// Handle Cancel CB from WM close
|
||||
int FileDialog::Private::CancelCB(FL_FORM *, void *)
|
||||
{
|
||||
// Simulate a click on the cancel button
|
||||
current_dlg_->Force(true);
|
||||
return FL_IGNORE;
|
||||
}
|
||||
|
||||
|
||||
// Simulates a click on OK/Cancel
|
||||
void FileDialog::Private::Force(bool cancel)
|
||||
{
|
||||
if (cancel) {
|
||||
force_cancel_ = true;
|
||||
fl_set_button(file_dlg_form_->Cancel, 1);
|
||||
} else {
|
||||
force_ok_ = true;
|
||||
fl_set_button(file_dlg_form_->Ready, 1);
|
||||
}
|
||||
// Start timer to break fl_do_forms loop soon
|
||||
fl_set_timer(file_dlg_form_->timer, 0.1);
|
||||
}
|
||||
|
||||
|
||||
// Select: launches dialog and returns selected file
|
||||
string const FileDialog::Private::Select(string const & title,
|
||||
string const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
{
|
||||
// handles new mask and path
|
||||
SetFilters(filters);
|
||||
SetDirectory(path);
|
||||
Reread();
|
||||
|
||||
// highlight the suggested file in the browser, if it exists.
|
||||
int sel = 0;
|
||||
string const filename = onlyFilename(suggested);
|
||||
if (!filename.empty()) {
|
||||
for (int i = 0; i < fl_get_browser_maxline(file_dlg_form_->List); ++i) {
|
||||
string s = fl_get_browser_line(file_dlg_form_->List, i + 1);
|
||||
s = trim(s);
|
||||
if (s == filename) {
|
||||
sel = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sel != 0)
|
||||
fl_select_browser_line(file_dlg_form_->List, sel);
|
||||
int const top = max(sel - 5, 1);
|
||||
fl_set_browser_topline(file_dlg_form_->List, top);
|
||||
|
||||
// checks whether dialog can be started
|
||||
if (current_dlg_)
|
||||
return string();
|
||||
current_dlg_ = this;
|
||||
|
||||
// runs dialog
|
||||
setEnabled(file_dlg_form_->Filename, true);
|
||||
fl_set_input(file_dlg_form_->Filename, suggested.c_str());
|
||||
fl_set_button(file_dlg_form_->Cancel, 0);
|
||||
fl_set_button(file_dlg_form_->Ready, 0);
|
||||
fl_set_focus_object(file_dlg_form_->form, file_dlg_form_->Filename);
|
||||
fl_deactivate_all_forms();
|
||||
// Prevent xforms crashing if the dialog gets too small by preventing
|
||||
// it from being shrunk beyond a minimum size.
|
||||
// calls to fl_set_form_minsize/maxsize apply only to the next
|
||||
// fl_show_form(), so this comes first.
|
||||
fl_set_form_minsize(file_dlg_form_->form, minw_, minh_);
|
||||
|
||||
fl_show_form(file_dlg_form_->form,
|
||||
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
|
||||
title.c_str());
|
||||
|
||||
bool const isOk = RunDialog();
|
||||
|
||||
fl_hide_form(file_dlg_form_->form);
|
||||
fl_activate_all_forms();
|
||||
current_dlg_ = 0;
|
||||
|
||||
// Returns filename or string() if no valid selection was made
|
||||
if (!isOk || !fl_get_input(file_dlg_form_->Filename)[0])
|
||||
return string();
|
||||
|
||||
file_name_ = fl_get_input(file_dlg_form_->Filename);
|
||||
|
||||
if (!absolutePath(file_name_))
|
||||
file_name_ = addName(fl_get_input(file_dlg_form_->DirBox), file_name_);
|
||||
return file_name_;
|
||||
}
|
||||
|
||||
|
||||
// SelectDir: launches dialog and returns selected directory
|
||||
string const FileDialog::Private::SelectDir(string const & title,
|
||||
string const & path,
|
||||
string const & suggested)
|
||||
{
|
||||
SetFilters("*/");
|
||||
// handles new path
|
||||
bool isOk = true;
|
||||
if (!path.empty()) {
|
||||
// handle case where path does not end with "/"
|
||||
// remerge path+suggested and check if it is a valid path
|
||||
if (!suggested.empty()) {
|
||||
string tmp = suggested;
|
||||
if (!suffixIs(tmp, '/'))
|
||||
tmp += '/';
|
||||
string const full_path = path + tmp;
|
||||
// check if this is really a directory
|
||||
if (fs::exists(full_path)
|
||||
&& fs::is_directory(full_path))
|
||||
SetDirectory(full_path);
|
||||
else
|
||||
SetDirectory(path);
|
||||
} else
|
||||
SetDirectory(path);
|
||||
isOk = false;
|
||||
}
|
||||
if (!isOk)
|
||||
Reread();
|
||||
|
||||
// checks whether dialog can be started
|
||||
if (current_dlg_)
|
||||
return string();
|
||||
current_dlg_ = this;
|
||||
|
||||
// runs dialog
|
||||
fl_set_input(file_dlg_form_->Filename, "");
|
||||
setEnabled(file_dlg_form_->Filename, false);
|
||||
fl_set_button(file_dlg_form_->Cancel, 0);
|
||||
fl_set_button(file_dlg_form_->Ready, 0);
|
||||
fl_set_focus_object(file_dlg_form_->form, file_dlg_form_->DirBox);
|
||||
fl_deactivate_all_forms();
|
||||
fl_show_form(file_dlg_form_->form,
|
||||
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
|
||||
title.c_str());
|
||||
|
||||
isOk = RunDialog();
|
||||
|
||||
fl_hide_form(file_dlg_form_->form);
|
||||
fl_activate_all_forms();
|
||||
current_dlg_ = 0;
|
||||
|
||||
// Returns directory or string() if no valid selection was made
|
||||
if (!isOk)
|
||||
return string();
|
||||
|
||||
file_name_ = fl_get_input(file_dlg_form_->DirBox);
|
||||
return file_name_;
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormFiledialog.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author unknown
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMFILEDIALOG_H
|
||||
#define FORMFILEDIALOG_H
|
||||
|
||||
#include "forms_fwd.h"
|
||||
|
||||
#include "frontends/FileDialog.h"
|
||||
|
||||
#include <boost/signals/connection.hpp>
|
||||
#include <boost/signals/trackable.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Dialogs;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace support {
|
||||
|
||||
class FileFilterList;
|
||||
|
||||
} // namespace support
|
||||
|
||||
|
||||
namespace frontend {
|
||||
|
||||
/// DirEntry internal structure definition
|
||||
class DirEntry {
|
||||
public:
|
||||
///
|
||||
std::string name_;
|
||||
///
|
||||
std::string displayed_;
|
||||
};
|
||||
|
||||
|
||||
//extern "C" {
|
||||
// void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data);
|
||||
// void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data);
|
||||
// int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev);
|
||||
//}
|
||||
|
||||
|
||||
class FD_filedialog;
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
||||
class FileDialog::Private : public boost::signals::trackable {
|
||||
public:
|
||||
///
|
||||
Private();
|
||||
///
|
||||
~Private();
|
||||
|
||||
/// sets file selector user button action
|
||||
void SetButton(int iIndex, std::string const & pszName = std::string(),
|
||||
std::string const & pszPath = std::string());
|
||||
/// gets last dialog directory
|
||||
std::string const GetDirectory() const;
|
||||
/// launches dialog and returns selected file
|
||||
std::string const Select(std::string const & pszTitle,
|
||||
std::string const & pszPath,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
std::string const & pszSuggested);
|
||||
/// launches dialog and returns selected directory
|
||||
std::string const SelectDir(std::string const & pszTitle = std::string(),
|
||||
std::string const & pszPath = std::string(),
|
||||
std::string const & pszSuggested = std::string());
|
||||
/// XForms objects callback (static)
|
||||
static void FileDlgCB(FL_OBJECT *, long);
|
||||
/// Callback for double click in list
|
||||
static void DoubleClickCB(FL_OBJECT *, long);
|
||||
/// Handle Cancel CB from WM close
|
||||
static int CancelCB(FL_FORM *, void *);
|
||||
|
||||
private:
|
||||
/// data
|
||||
static lyx::frontend::FD_filedialog * file_dlg_form_;
|
||||
///
|
||||
static FileDialog::Private * current_dlg_;
|
||||
///
|
||||
static int minw_;
|
||||
///
|
||||
static int minh_;
|
||||
///
|
||||
std::string user_path1_;
|
||||
///
|
||||
std::string user_path2_;
|
||||
///
|
||||
std::string directory_;
|
||||
///
|
||||
std::string mask_;
|
||||
///
|
||||
std::string file_name_;
|
||||
///
|
||||
int depth_;
|
||||
///
|
||||
int last_sel_;
|
||||
///
|
||||
long last_time_;
|
||||
///
|
||||
typedef std::vector<lyx::frontend::DirEntry> DirEntries;
|
||||
///
|
||||
DirEntries dir_entries_;
|
||||
///
|
||||
bool force_cancel_;
|
||||
///
|
||||
bool force_ok_;
|
||||
|
||||
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||
that the xform colors have been re-mapped).
|
||||
*/
|
||||
void redraw();
|
||||
/// updates dialog list to match class directory
|
||||
void Reread();
|
||||
/// sets dialog current directory
|
||||
void SetDirectory(std::string const & pszPath);
|
||||
/// sets dialog file mask
|
||||
void SetFilters(std::string const & filters);
|
||||
void SetFilters(lyx::support::FileFilterList const & filters);
|
||||
/// handle dialog during file selection
|
||||
bool RunDialog();
|
||||
/// Handle callback from list
|
||||
void HandleListHit();
|
||||
/// Handle double click from list
|
||||
bool HandleDoubleClick();
|
||||
/// Handle OK button call
|
||||
bool HandleOK();
|
||||
/// Simulates a click on OK/Cancel
|
||||
void Force(bool);
|
||||
/// Redraw connection.
|
||||
boost::signals::connection r_;
|
||||
};
|
||||
|
||||
#endif // FORMFILEDIALOG_H
|
@ -1,262 +0,0 @@
|
||||
/**
|
||||
* \file FormFloat.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
* \author Jürgen Spitzmüller
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormFloat.h"
|
||||
#include "ControlFloat.h"
|
||||
#include "forms/form_float.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "insets/insetfloat.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::contains;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
DOCUMENT_DEFAULTS,
|
||||
HERE_DEFINITELY,
|
||||
ALTERNATIVES
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlFloat, FormView<FD_float> > base_class;
|
||||
|
||||
FormFloat::FormFloat(Dialog & parent)
|
||||
: base_class(parent, _("Float Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormFloat::build()
|
||||
{
|
||||
dialog_.reset(build_float(this));
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->radio_default);
|
||||
bcview().addReadOnly(dialog_->radio_here_definitely);
|
||||
bcview().addReadOnly(dialog_->radio_alternatives);
|
||||
bcview().addReadOnly(dialog_->check_top);
|
||||
bcview().addReadOnly(dialog_->check_bottom);
|
||||
bcview().addReadOnly(dialog_->check_page);
|
||||
bcview().addReadOnly(dialog_->check_here);
|
||||
bcview().addReadOnly(dialog_->check_force);
|
||||
bcview().addReadOnly(dialog_->check_wide);
|
||||
bcview().addReadOnly(dialog_->check_sideways);
|
||||
|
||||
placement_.init(dialog_->radio_default, DOCUMENT_DEFAULTS);
|
||||
placement_.init(dialog_->radio_here_definitely, HERE_DEFINITELY);
|
||||
placement_.init(dialog_->radio_alternatives, ALTERNATIVES);
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("Use the document's default settings.");
|
||||
tooltips().init(dialog_->radio_default, str);
|
||||
str = _("Enforce placement of float here.");
|
||||
tooltips().init(dialog_->radio_here_definitely, str);
|
||||
str = _("Alternative suggestions for placement of float.");
|
||||
tooltips().init(dialog_->radio_alternatives, str);
|
||||
str = _("Try top of page.");
|
||||
tooltips().init(dialog_->check_top, str);
|
||||
str = _("Try bottom of page.");
|
||||
tooltips().init(dialog_->check_bottom, str);
|
||||
str = _("Put float on a separate page of floats.");
|
||||
tooltips().init(dialog_->check_page, str);
|
||||
str = _("Try float here.");
|
||||
tooltips().init(dialog_->check_here, str);
|
||||
str = _("Ignore internal settings. This is the \"!\" in LaTeX.");
|
||||
tooltips().init(dialog_->check_force, str);
|
||||
str = _("Span float over the columns.");
|
||||
tooltips().init(dialog_->check_wide, str);
|
||||
str = _("Rotate the float sideways by 90 degs.");
|
||||
tooltips().init(dialog_->check_sideways, str);
|
||||
}
|
||||
|
||||
|
||||
void FormFloat::apply()
|
||||
{
|
||||
bool const wide = fl_get_button(dialog_->check_wide);
|
||||
bool const sideways = fl_get_button(dialog_->check_sideways);
|
||||
|
||||
string placement;
|
||||
switch (placement_.get()) {
|
||||
case ALTERNATIVES:
|
||||
if (fl_get_button(dialog_->check_force)) {
|
||||
// Ignore internal LaTeX rules
|
||||
placement += '!';
|
||||
}
|
||||
if (fl_get_button(dialog_->check_top)) {
|
||||
// Top of page
|
||||
placement += 't';
|
||||
}
|
||||
if (fl_get_button(dialog_->check_bottom)) {
|
||||
// Bottom of page
|
||||
placement += 'b';
|
||||
}
|
||||
if (fl_get_button(dialog_->check_page)) {
|
||||
// Page of floats
|
||||
placement += 'p';
|
||||
}
|
||||
// ignore if wide is selected
|
||||
if (!wide && fl_get_button(dialog_->check_here)) {
|
||||
// Here, if possible
|
||||
placement += 'h';
|
||||
}
|
||||
if (placement == "!") {
|
||||
// ignore placement if only force is selected.
|
||||
placement.erase();
|
||||
}
|
||||
|
||||
if (placement.length() == 0) {
|
||||
// none of Alternatives is selected; flip to default
|
||||
placement.erase();
|
||||
placement_.set(dialog_->radio_default);
|
||||
setEnabled(dialog_->check_force, false);
|
||||
setEnabled(dialog_->check_top, false);
|
||||
setEnabled(dialog_->check_bottom, false);
|
||||
setEnabled(dialog_->check_page, false);
|
||||
setEnabled(dialog_->check_here, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case HERE_DEFINITELY:
|
||||
placement = "H";
|
||||
break;
|
||||
|
||||
case DOCUMENT_DEFAULTS:
|
||||
// default, do nothing.
|
||||
break;
|
||||
}
|
||||
|
||||
controller().params().placement = placement;
|
||||
controller().params().wide = wide;
|
||||
controller().params().sideways = sideways;
|
||||
}
|
||||
|
||||
|
||||
void FormFloat::update()
|
||||
{
|
||||
string placement(controller().params().placement);
|
||||
bool const wide = controller().params().wide;
|
||||
bool const sideways = controller().params().sideways;
|
||||
bool const sideways_possible = (controller().params().type == "figure"
|
||||
|| controller().params().type == "table");
|
||||
|
||||
bool const here_definitely = contains(placement, 'H');
|
||||
|
||||
bool const top = contains(placement, 't');
|
||||
bool const bottom = contains(placement, 'b');
|
||||
bool const page = contains(placement, 'p');
|
||||
bool const here = contains(placement, 'h');
|
||||
bool const force = contains(placement, '!');
|
||||
bool const alternatives = top || bottom || page || (here && !wide);
|
||||
|
||||
if (alternatives) {
|
||||
placement_.set(dialog_->radio_alternatives);
|
||||
} else if (here_definitely) {
|
||||
placement_.set(dialog_->radio_here_definitely);
|
||||
} else {
|
||||
placement_.set(dialog_->radio_default);
|
||||
}
|
||||
fl_set_button(dialog_->check_force, force);
|
||||
fl_set_button(dialog_->check_top, top);
|
||||
fl_set_button(dialog_->check_bottom, bottom);
|
||||
fl_set_button(dialog_->check_page, page);
|
||||
fl_set_button(dialog_->check_here, here);
|
||||
fl_set_button(dialog_->check_wide, wide);
|
||||
fl_set_button(dialog_->check_sideways, sideways);
|
||||
|
||||
setEnabled(dialog_->radio_here_definitely, !wide && !sideways);
|
||||
setEnabled(dialog_->check_force, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_top, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_bottom, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_page, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_here, alternatives && !wide && !sideways);
|
||||
setEnabled(dialog_->check_wide, !sideways);
|
||||
setEnabled(dialog_->radio_default, !sideways);
|
||||
setEnabled(dialog_->radio_alternatives, !sideways);
|
||||
setEnabled(dialog_->check_sideways, sideways_possible);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
bool const alternatives = placement_.get() == ALTERNATIVES;
|
||||
bool const wide = fl_get_button(dialog_->check_wide);
|
||||
bool const sideways = fl_get_button(dialog_->check_sideways);
|
||||
|
||||
if (ob == dialog_->radio_default ||
|
||||
ob == dialog_->radio_here_definitely ||
|
||||
ob == dialog_->radio_alternatives) {
|
||||
// enable check buttons only for Alternatives
|
||||
setEnabled(dialog_->check_top, alternatives);
|
||||
setEnabled(dialog_->check_page, alternatives);
|
||||
// wide float doesn't allow 'here' or 'bottom' placement
|
||||
setEnabled(dialog_->check_here, alternatives && !wide);
|
||||
setEnabled(dialog_->check_bottom, alternatives && !wide);
|
||||
|
||||
} else if (ob == dialog_->check_wide) {
|
||||
if (wide && placement_.get() == HERE_DEFINITELY) {
|
||||
// wide float doesn't allow 'Here, definitely!'
|
||||
// placement
|
||||
placement_.set(dialog_->radio_default);
|
||||
}
|
||||
setEnabled(dialog_->check_here, alternatives && !wide);
|
||||
setEnabled(dialog_->radio_here_definitely, !wide);
|
||||
setEnabled(dialog_->check_bottom, alternatives && !wide);
|
||||
|
||||
} else if (ob == dialog_->check_sideways) {
|
||||
setEnabled(dialog_->radio_default, !sideways);
|
||||
setEnabled(dialog_->radio_alternatives, !sideways);
|
||||
setEnabled(dialog_->radio_here_definitely, !wide && !sideways);
|
||||
setEnabled(dialog_->check_top, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_bottom,
|
||||
alternatives && !wide && !sideways);
|
||||
setEnabled(dialog_->check_page, alternatives && !sideways);
|
||||
setEnabled(dialog_->check_here, alternatives && !wide && !sideways);
|
||||
setEnabled(dialog_->check_wide, !sideways);
|
||||
}
|
||||
|
||||
// enable force button, if Alternatives is selected and at least
|
||||
// one of its check buttons
|
||||
bool const enable_force = alternatives && !sideways &&
|
||||
(fl_get_button(dialog_->check_top) ||
|
||||
fl_get_button(dialog_->check_bottom) ||
|
||||
fl_get_button(dialog_->check_page) ||
|
||||
(fl_get_button(dialog_->check_here) && !wide));
|
||||
setEnabled(dialog_->check_force, enable_force);
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,48 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormFloat.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMFLOAT_H
|
||||
#define FORMFLOAT_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "RadioButtonGroup.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlFloat;
|
||||
struct FD_float;
|
||||
|
||||
/** This class provides an XForms implementation of the Float
|
||||
Dialog.
|
||||
*/
|
||||
class FormFloat : public FormController<ControlFloat, FormView<FD_float> > {
|
||||
public:
|
||||
///
|
||||
FormFloat(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/// placement
|
||||
RadioButtonGroup placement_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMFLOAT_H
|
@ -1,671 +0,0 @@
|
||||
/**
|
||||
* \file FormGraphics.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Baruch Even
|
||||
* \author Herbert Voß
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormGraphics.h"
|
||||
#include "ControlGraphics.h"
|
||||
#include "forms/form_graphics.h"
|
||||
|
||||
#include "controllers/helper_funcs.h"
|
||||
|
||||
#include "checkedwidgets.h"
|
||||
#include "input_validators.h"
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyxrc.h" // for lyxrc.display_graphics
|
||||
|
||||
#include "insets/insetgraphicsParams.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
|
||||
#include "support/lyxlib.h" // for float_equal
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::floor;
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::bformat;
|
||||
using support::float_equal;
|
||||
using support::getStringFromVector;
|
||||
using support::token;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
// Bound the number of input characters
|
||||
int const SIZE_MAXDIGITS = 10;
|
||||
int const FILENAME_MAXCHARS = 1024;
|
||||
|
||||
string defaultUnit("cm");
|
||||
|
||||
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
|
||||
bool const scalableTabfolders = false;
|
||||
#else
|
||||
bool const scalableTabfolders = true;
|
||||
#endif
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlGraphics, FormView<FD_graphics> > base_class;
|
||||
|
||||
FormGraphics::FormGraphics(Dialog & parent)
|
||||
: base_class(parent, _("Graphics"), scalableTabfolders),
|
||||
file_checker_(0)
|
||||
{}
|
||||
|
||||
|
||||
void FormGraphics::redraw()
|
||||
{
|
||||
if (form() && form()->visible)
|
||||
fl_redraw_form(form());
|
||||
else
|
||||
return;
|
||||
FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
|
||||
if (outer_form && outer_form->visible)
|
||||
fl_redraw_form(outer_form);
|
||||
}
|
||||
|
||||
|
||||
void FormGraphics::build()
|
||||
{
|
||||
dialog_.reset(build_graphics(this));
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
// The file section.
|
||||
file_.reset(build_graphics_file(this));
|
||||
|
||||
// Disable for read-only documents.
|
||||
bcview().addReadOnly(file_->button_browse);
|
||||
bcview().addReadOnly(file_->check_aspectratio);
|
||||
bcview().addReadOnly(file_->check_draft);
|
||||
bcview().addReadOnly(file_->check_nounzip);
|
||||
|
||||
file_checker_ = &addCheckedPath(bcview(), true, file_->input_filename);
|
||||
|
||||
// Check validity of "length + unit" input.
|
||||
addCheckedGlueLength(bcview(), file_->input_width);
|
||||
addCheckedGlueLength(bcview(), file_->input_height);
|
||||
|
||||
// Trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(file_->input_filename);
|
||||
setPrehandler(file_->input_lyxscale);
|
||||
setPrehandler(file_->input_width);
|
||||
setPrehandler(file_->input_height);
|
||||
|
||||
// Activate ok/apply immediately upon input.
|
||||
fl_set_input_return(file_->input_filename, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(file_->input_lyxscale, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(file_->input_width, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(file_->input_height, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
|
||||
fl_set_input_filter(file_->input_lyxscale, fl_unsigned_int_filter);
|
||||
|
||||
// Width default is scaling: use unsigned float filter.
|
||||
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
|
||||
fl_set_input_maxchars(file_->input_height, SIZE_MAXDIGITS);
|
||||
|
||||
string const display_List =
|
||||
_("Default|Monochrome|Grayscale|Color|Do not display");
|
||||
fl_addto_choice(file_->choice_display, display_List.c_str());
|
||||
|
||||
string const height_list = buildChoiceLengthString();
|
||||
string const width_list = bformat(_("Scale%%%%|%1$s"), height_list);
|
||||
|
||||
fl_addto_choice(file_->choice_width, width_list.c_str());
|
||||
fl_addto_choice(file_->choice_height, height_list.c_str());
|
||||
|
||||
// set up the tooltips for the filesection
|
||||
string str = _("The file you want to insert.");
|
||||
tooltips().init(file_->input_filename, str);
|
||||
str = _("Browse the directories.");
|
||||
tooltips().init(file_->button_browse, str);
|
||||
|
||||
str = _("Scale the image to inserted percentage value.");
|
||||
tooltips().init(file_->input_lyxscale, str);
|
||||
str = _("Select display mode for this image.");
|
||||
tooltips().init(file_->choice_display, str);
|
||||
|
||||
str = _("Set the image width to the inserted value.");
|
||||
tooltips().init(file_->input_width, str);
|
||||
// xgettext:no-c-format
|
||||
str = _("Select unit for width; Scale% for scaling whole image.");
|
||||
tooltips().init(file_->choice_width, str);
|
||||
str = _("Set the image height to the inserted value.");
|
||||
tooltips().init(file_->input_height, str);
|
||||
str = _("Select unit for height.");
|
||||
tooltips().init(file_->choice_height, str);
|
||||
str = _("Do not distort the image. "
|
||||
"Keep image within \"width\" by \"height\" and obey "
|
||||
"aspect ratio.");
|
||||
tooltips().init(file_->check_aspectratio, str);
|
||||
str = _("Pass a filename like \"file.eps.gz\" to the LaTeX output. "
|
||||
"Useful when LaTeX should unzip the file. Needs an additional "
|
||||
"file like \"file.eps.bb\" which holds the values for "
|
||||
"the bounding box.");
|
||||
tooltips().init(file_->check_nounzip, str);
|
||||
str = _("Show image only as a rectangle of the original size.");
|
||||
tooltips().init(file_->check_draft, str);
|
||||
|
||||
// the bounding box selection
|
||||
bbox_.reset(build_graphics_bbox(this));
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(bbox_->button_getBB);
|
||||
bcview().addReadOnly(bbox_->check_clip);
|
||||
|
||||
// check validity of "length + unit" input
|
||||
addCheckedLyXLength(bcview(), bbox_->input_bb_x1, bbox_->text_X);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(bbox_->input_bb_x0);
|
||||
setPrehandler(bbox_->input_bb_y0);
|
||||
setPrehandler(bbox_->input_bb_x1);
|
||||
setPrehandler(bbox_->input_bb_y1);
|
||||
|
||||
// for activate ok/apply immediately upon input
|
||||
fl_set_input_return(bbox_->input_bb_x0, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(bbox_->input_bb_y0, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(bbox_->input_bb_x1, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(bbox_->input_bb_y1, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_input_filter(bbox_->input_bb_x0, fl_unsigned_float_filter);
|
||||
fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter);
|
||||
fl_set_input_filter(bbox_->input_bb_y1, fl_unsigned_float_filter);
|
||||
|
||||
string const bb_units = getStringFromVector(getBBUnits(), "|");
|
||||
fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str());
|
||||
|
||||
// set up the tooltips for the bounding-box-section
|
||||
str = _("The lower left x-value of the bounding box.");
|
||||
tooltips().init(bbox_->input_bb_x0, str);
|
||||
str = _("The lower left y-value of the bounding box.");
|
||||
tooltips().init(bbox_->input_bb_y0, str);
|
||||
str = _("The upper right x-value of the bounding box; "
|
||||
"only this input field allows length + unit, e.g. 5cm "
|
||||
"and sets the unit for the other input fields.");
|
||||
tooltips().init(bbox_->input_bb_x1, str);
|
||||
str = _("The upper right y-value of the bounding box.");
|
||||
tooltips().init(bbox_->input_bb_y1, str);
|
||||
str = _("Select unit for the bounding box values.");
|
||||
tooltips().init(bbox_->choice_bb_units, str);
|
||||
|
||||
str = _("Read the image coordinates new from file. For (e)ps-file "
|
||||
"the bounding box is read, otherwise the imagesize in pixels. "
|
||||
"Default unit is \"bp\", the PostScript's b(ig) p(oint).");
|
||||
tooltips().init(bbox_->button_getBB, str);
|
||||
|
||||
str = _("Clip image to the bounding box values.");
|
||||
tooltips().init(bbox_->check_clip, str);
|
||||
|
||||
// the extra section
|
||||
extra_.reset(build_graphics_extra(this));
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(extra_->input_rotate_angle);
|
||||
bcview().addReadOnly(extra_->choice_origin);
|
||||
bcview().addReadOnly(extra_->check_subcaption);
|
||||
bcview().addReadOnly(extra_->input_special);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(extra_->input_rotate_angle);
|
||||
setPrehandler(extra_->input_subcaption);
|
||||
setPrehandler(extra_->input_special);
|
||||
|
||||
fl_set_input_return(extra_->input_rotate_angle, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(extra_->input_subcaption, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(extra_->input_special, FL_RETURN_CHANGED);
|
||||
|
||||
fl_set_input_filter(extra_->input_rotate_angle, fl_float_filter);
|
||||
|
||||
vector<RotationOriginPair> origindata = getRotationOriginData();
|
||||
|
||||
// Store the identifiers for later
|
||||
origins_ = getSecond(origindata);
|
||||
|
||||
string const choice = getStringFromVector(getFirst(origindata), "|");
|
||||
fl_addto_choice(extra_->choice_origin, choice.c_str());
|
||||
|
||||
// set up the tooltips for the extra section
|
||||
str = _("Insert the rotation angle in degrees. "
|
||||
"Positive value rotates anti-clockwise, "
|
||||
"negative value clockwise.");
|
||||
tooltips().init(extra_->input_rotate_angle, str);
|
||||
str = _("Insert the point of origin for rotation.");
|
||||
tooltips().init(extra_->choice_origin, str);
|
||||
str = _("Enables use of subfigure with its own caption.");
|
||||
tooltips().init(extra_->check_subcaption, str);
|
||||
str = _("Insert the optional subfigure caption.");
|
||||
tooltips().init(extra_->input_subcaption, str);
|
||||
str = _("Add any additional LaTeX option, which is defined in the "
|
||||
"graphicx-package and not mentioned in the gui's tabfolders.");
|
||||
tooltips().init(extra_->input_special, str);
|
||||
|
||||
// Enable the tabfolder to be rescaled correctly.
|
||||
if (scalableTabfolders)
|
||||
fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
|
||||
|
||||
// Stack tabs
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("File").c_str(),
|
||||
file_->form);
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box").c_str(),
|
||||
bbox_->form);
|
||||
fl_addto_tabfolder(dialog_->tabfolder, _("Extra").c_str(),
|
||||
extra_->form);
|
||||
|
||||
// set the right default unit
|
||||
defaultUnit = "cm";
|
||||
switch (lyxrc.default_papersize) {
|
||||
case PAPER_USLETTER:
|
||||
case PAPER_USLEGAL:
|
||||
case PAPER_USEXECUTIVE:
|
||||
defaultUnit = "in";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormGraphics::apply()
|
||||
{
|
||||
// Create the parameters structure and fill the data from the dialog.
|
||||
InsetGraphicsParams & igp = controller().params();
|
||||
|
||||
// the file section
|
||||
igp.filename.set(getString(file_->input_filename),
|
||||
kernel().bufferFilepath());
|
||||
|
||||
igp.lyxscale = convert<int>(getString(file_->input_lyxscale));
|
||||
if (igp.lyxscale == 0) {
|
||||
igp.lyxscale = 100;
|
||||
}
|
||||
|
||||
switch (fl_get_choice(file_->choice_display)) {
|
||||
case 5:
|
||||
igp.display = graphics::NoDisplay;
|
||||
break;
|
||||
case 4:
|
||||
igp.display = graphics::ColorDisplay;
|
||||
break;
|
||||
case 3:
|
||||
igp.display = graphics::GrayscaleDisplay;
|
||||
break;
|
||||
case 2:
|
||||
igp.display = graphics::MonochromeDisplay;
|
||||
break;
|
||||
case 1:
|
||||
igp.display = graphics::DefaultDisplay;
|
||||
}
|
||||
|
||||
// first item in choice_width means scaling
|
||||
if (fl_get_choice(file_->choice_width) == 1) {
|
||||
igp.scale = getString(file_->input_width);
|
||||
if (igp.scale.empty()
|
||||
|| float_equal(convert<double>(igp.scale), 0.0, 0.05)
|
||||
|| float_equal(convert<double>(igp.scale), 100.0, 0.05)) {
|
||||
igp.scale.erase();
|
||||
}
|
||||
igp.width = LyXLength();
|
||||
} else {
|
||||
igp.scale.erase();
|
||||
igp.width = LyXLength(getLengthFromWidgets(file_->input_width,
|
||||
file_->choice_width));
|
||||
}
|
||||
igp.height = LyXLength(getLengthFromWidgets(file_->input_height,
|
||||
file_->choice_height));
|
||||
igp.keepAspectRatio = fl_get_button(file_->check_aspectratio);
|
||||
|
||||
igp.draft = fl_get_button(file_->check_draft);
|
||||
igp.noUnzip = fl_get_button(file_->check_nounzip);
|
||||
|
||||
// the bb section
|
||||
if (!controller().bbChanged) {
|
||||
// don't write anything
|
||||
igp.bb.erase();
|
||||
} else {
|
||||
// allow length + unit input only for x1 input field
|
||||
string x1_str = "0";
|
||||
if (!getString(bbox_->input_bb_x1).empty()) {
|
||||
x1_str = getLengthFromWidgets(bbox_->input_bb_x1,
|
||||
bbox_->choice_bb_units);
|
||||
LyXLength x1 = LyXLength(x1_str);
|
||||
x1_str = x1.asString();
|
||||
|
||||
string unit;
|
||||
switch (x1.unit()) {
|
||||
case LyXLength::IN:
|
||||
unit = "in";
|
||||
break;
|
||||
case LyXLength::MM:
|
||||
unit = "mm";
|
||||
break;
|
||||
case LyXLength::CM:
|
||||
unit = "cm";
|
||||
break;
|
||||
case LyXLength::BP:
|
||||
default:
|
||||
unit = "bp";
|
||||
}
|
||||
fl_set_choice_text(bbox_->choice_bb_units, unit.c_str());
|
||||
}
|
||||
|
||||
string bb;
|
||||
if (getString(bbox_->input_bb_x0).empty())
|
||||
bb = "0";
|
||||
else
|
||||
bb = getLengthFromWidgets(bbox_->input_bb_x0,
|
||||
bbox_->choice_bb_units);
|
||||
|
||||
bb += ' ';
|
||||
|
||||
if (getString(bbox_->input_bb_y0).empty())
|
||||
bb += '0';
|
||||
else
|
||||
bb += getLengthFromWidgets(bbox_->input_bb_y0,
|
||||
bbox_->choice_bb_units);
|
||||
|
||||
bb += ' ' + x1_str + ' ';
|
||||
|
||||
if (getString(bbox_->input_bb_y1).empty())
|
||||
bb += '0';
|
||||
else
|
||||
bb += getLengthFromWidgets(bbox_->input_bb_y1,
|
||||
bbox_->choice_bb_units);
|
||||
|
||||
igp.bb = bb;
|
||||
}
|
||||
igp.clip = fl_get_button(bbox_->check_clip);
|
||||
|
||||
// the extra section
|
||||
igp.rotateAngle = getString(extra_->input_rotate_angle);
|
||||
|
||||
// map angle into -360 (clock-wise) to +360 (counter clock-wise)
|
||||
double rotAngle = convert<double>(igp.rotateAngle);
|
||||
if (std::abs(rotAngle) > 360.0) {
|
||||
rotAngle -= 360.0 * floor(rotAngle / 360.0);
|
||||
igp.rotateAngle = convert<string>(rotAngle);
|
||||
}
|
||||
|
||||
fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str());
|
||||
|
||||
int const origin_pos = fl_get_choice(extra_->choice_origin);
|
||||
if (origin_pos == 0) {
|
||||
igp.rotateOrigin.erase();
|
||||
} else {
|
||||
igp.rotateOrigin = origins_[origin_pos - 1];
|
||||
}
|
||||
|
||||
igp.subcaption = fl_get_button(extra_->check_subcaption);
|
||||
igp.subcaptionText = getString(extra_->input_subcaption);
|
||||
|
||||
igp.special = getString(extra_->input_special);
|
||||
}
|
||||
|
||||
|
||||
void FormGraphics::update()
|
||||
{
|
||||
file_checker_->setChecker(kernel().docType(), lyxrc);
|
||||
|
||||
// Update dialog with details from inset
|
||||
InsetGraphicsParams & igp = controller().params();
|
||||
|
||||
// the file section
|
||||
string const name =
|
||||
igp.filename.outputFilename(kernel().bufferFilepath());
|
||||
fl_set_input(file_->input_filename, name.c_str());
|
||||
fl_set_input(file_->input_lyxscale, convert<string>(igp.lyxscale).c_str());
|
||||
|
||||
switch (igp.display) {
|
||||
case graphics::NoDisplay:
|
||||
fl_set_choice(file_->choice_display, 5);
|
||||
break;
|
||||
case graphics::ColorDisplay:
|
||||
fl_set_choice(file_->choice_display, 4);
|
||||
break;
|
||||
case graphics::GrayscaleDisplay:
|
||||
fl_set_choice(file_->choice_display, 3);
|
||||
break;
|
||||
case graphics::MonochromeDisplay:
|
||||
fl_set_choice(file_->choice_display, 2);
|
||||
break;
|
||||
case graphics::DefaultDisplay:
|
||||
fl_set_choice(file_->choice_display, 1);
|
||||
}
|
||||
|
||||
// set width input fields according to scaling or width/height input
|
||||
if (!igp.scale.empty() && !float_equal(convert<double>(igp.scale), 0.0, 0.05)) {
|
||||
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
|
||||
fl_set_input_maxchars(file_->input_width, 0);
|
||||
fl_set_input(file_->input_width, igp.scale.c_str());
|
||||
fl_set_choice(file_->choice_width, 1);
|
||||
} else {
|
||||
fl_set_input_filter(file_->input_width, NULL);
|
||||
fl_set_input_maxchars(file_->input_width, SIZE_MAXDIGITS);
|
||||
updateWidgetsFromLength(file_->input_width, file_->choice_width,
|
||||
igp.width, defaultUnit);
|
||||
}
|
||||
|
||||
updateWidgetsFromLength(file_->input_height, file_->choice_height,
|
||||
igp.height, defaultUnit);
|
||||
|
||||
// disable height input in case of scaling
|
||||
bool const disable_height = (!igp.scale.empty()
|
||||
&& !float_equal(convert<double>(igp.scale), 0.0, 0.05));
|
||||
setEnabled(file_->input_height, !disable_height);
|
||||
setEnabled(file_->choice_height, !disable_height);
|
||||
|
||||
fl_set_button(file_->check_aspectratio, igp.keepAspectRatio);
|
||||
fl_set_button(file_->check_draft, igp.draft);
|
||||
fl_set_button(file_->check_nounzip, igp.noUnzip);
|
||||
|
||||
// disable aspectratio button in case of scaling or one of width/height
|
||||
// is empty
|
||||
bool const disable_aspectRatio = disable_height ||
|
||||
getString(file_->input_width).empty() ||
|
||||
getString(file_->input_height).empty();
|
||||
setEnabled(file_->check_aspectratio, !disable_aspectRatio);
|
||||
|
||||
// the bb section
|
||||
// set the bounding box values, if exists. First we need the whole
|
||||
// path, because the controller knows nothing about the doc-dir
|
||||
updateBB(igp.filename.absFilename(), igp.bb);
|
||||
fl_set_button(bbox_->check_clip, igp.clip);
|
||||
|
||||
// the extra section
|
||||
fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str());
|
||||
|
||||
int origin_pos = 1;
|
||||
if (!igp.rotateOrigin.empty()) {
|
||||
origin_pos += findPos(origins_, igp.rotateOrigin);
|
||||
}
|
||||
fl_set_choice(extra_->choice_origin, origin_pos);
|
||||
|
||||
fl_set_button(extra_->check_subcaption, igp.subcaption);
|
||||
fl_set_input(extra_->input_subcaption, igp.subcaptionText.c_str());
|
||||
setEnabled(extra_->input_subcaption,
|
||||
fl_get_button(extra_->check_subcaption));
|
||||
fl_set_input(extra_->input_special, igp.special.c_str());
|
||||
|
||||
// open dialog in the file-tab, whenever filename is empty
|
||||
if (igp.filename.empty()) {
|
||||
fl_set_folder(dialog_->tabfolder, file_->form);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormGraphics::updateBB(string const & filename, string const & bb_inset)
|
||||
{
|
||||
// Update dialog with details from inset
|
||||
// set the bounding box values, if exists. First we need the whole
|
||||
// path, because the controller knows nothing about the doc-dir
|
||||
controller().bbChanged = false;
|
||||
if (bb_inset.empty()) {
|
||||
lyxerr[Debug::GRAPHICS]
|
||||
<< "FormGraphics::updateBB() [no BoundingBox]" << endl;
|
||||
string const bb = controller().readBB(filename);
|
||||
if (!bb.empty()) {
|
||||
// get the values from the file
|
||||
// in this case we always have the point-unit
|
||||
fl_set_input(bbox_->input_bb_x0,
|
||||
token(bb,' ',0).c_str());
|
||||
fl_set_input(bbox_->input_bb_y0,
|
||||
token(bb,' ',1).c_str());
|
||||
fl_set_input(bbox_->input_bb_x1,
|
||||
token(bb,' ',2).c_str());
|
||||
fl_set_input(bbox_->input_bb_y1,
|
||||
token(bb,' ',3).c_str());
|
||||
|
||||
} else {
|
||||
// no bb from file
|
||||
fl_set_input(bbox_->input_bb_x0, bb.c_str());
|
||||
fl_set_input(bbox_->input_bb_y0, bb.c_str());
|
||||
fl_set_input(bbox_->input_bb_x1, bb.c_str());
|
||||
fl_set_input(bbox_->input_bb_y1, bb.c_str());
|
||||
}
|
||||
// "bp"
|
||||
fl_set_choice(bbox_->choice_bb_units, 1);
|
||||
|
||||
} else {
|
||||
// get the values from the inset
|
||||
lyxerr[Debug::GRAPHICS]
|
||||
<< "FormGraphics::updateBB(): igp has BoundingBox"
|
||||
<< " ["<< bb_inset << "]" << endl;
|
||||
controller().bbChanged = true;
|
||||
|
||||
LyXLength anyLength;
|
||||
anyLength = LyXLength(token(bb_inset,' ',0));
|
||||
updateWidgetsFromLength(bbox_->input_bb_x0,
|
||||
bbox_->choice_bb_units,anyLength,"bp");
|
||||
anyLength = LyXLength(token(bb_inset,' ',1));
|
||||
updateWidgetsFromLength(bbox_->input_bb_y0,
|
||||
bbox_->choice_bb_units,anyLength,"bp");
|
||||
anyLength = LyXLength(token(bb_inset,' ',2));
|
||||
updateWidgetsFromLength(bbox_->input_bb_x1,
|
||||
bbox_->choice_bb_units,anyLength,"bp");
|
||||
anyLength = LyXLength(token(bb_inset,' ',3));
|
||||
updateWidgetsFromLength(bbox_->input_bb_y1,
|
||||
bbox_->choice_bb_units,anyLength,"bp");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
// the file section
|
||||
if (ob == file_->button_browse) {
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
// Get the filename from the dialog
|
||||
string const in_name = getString(file_->input_filename);
|
||||
string const out_name = controller().browse(in_name);
|
||||
lyxerr[Debug::GRAPHICS]
|
||||
<< "[FormGraphics]out_name: " << out_name << endl;
|
||||
if (out_name != in_name && !out_name.empty()) {
|
||||
fl_set_input(file_->input_filename, out_name.c_str());
|
||||
}
|
||||
if (controller().isFilenameValid(out_name) &&
|
||||
!controller().bbChanged) {
|
||||
updateBB(out_name, string());
|
||||
}
|
||||
} else if (ob == file_->input_width || ob == file_->input_height) {
|
||||
// disable aspectratio button in case of scaling or one of
|
||||
// width/height is empty
|
||||
bool const disable = fl_get_choice(file_->choice_width) == 1 ||
|
||||
getString(file_->input_width).empty() ||
|
||||
getString(file_->input_height).empty();
|
||||
setEnabled(file_->check_aspectratio, !disable);
|
||||
} else if (ob == file_->choice_width) {
|
||||
// disable height input in case of scaling
|
||||
bool const scaling = fl_get_choice(file_->choice_width) == 1;
|
||||
setEnabled(file_->input_height, !scaling);
|
||||
setEnabled(file_->choice_height, !scaling);
|
||||
|
||||
// allow only integer intput for scaling; float otherwise
|
||||
if (scaling) {
|
||||
fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
|
||||
fl_set_input_maxchars(file_->input_width, 0);
|
||||
} else {
|
||||
fl_set_input_filter(file_->input_width, NULL);
|
||||
fl_set_input_maxchars(file_->input_width, SIZE_MAXDIGITS);
|
||||
}
|
||||
|
||||
// disable aspectratio button in case of scaling or height
|
||||
// input is empty
|
||||
bool const disable_aspectratio =
|
||||
scaling || getString(file_->input_height).empty();
|
||||
setEnabled(file_->check_aspectratio, !disable_aspectratio);
|
||||
// the bb section
|
||||
} else if (!controller().bbChanged &&
|
||||
(ob == bbox_->check_clip || ob == bbox_->choice_bb_units ||
|
||||
ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 ||
|
||||
ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) {
|
||||
controller().bbChanged = true;
|
||||
} else if (ob == bbox_->button_getBB) {
|
||||
string const filename = getString(file_->input_filename);
|
||||
if (!filename.empty()) {
|
||||
string bb = controller().readBB(filename);
|
||||
if (!bb.empty()) {
|
||||
fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
|
||||
fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
|
||||
fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
|
||||
fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
|
||||
fl_set_choice_text(bbox_->choice_bb_units, "bp");
|
||||
}
|
||||
controller().bbChanged = false;
|
||||
} else {
|
||||
fl_set_input(bbox_->input_bb_x0, "");
|
||||
fl_set_input(bbox_->input_bb_y0, "");
|
||||
fl_set_input(bbox_->input_bb_x1, "");
|
||||
fl_set_input(bbox_->input_bb_y1, "");
|
||||
fl_set_choice_text(bbox_->choice_bb_units, "bp");
|
||||
}
|
||||
// the extra section
|
||||
} else if (ob == extra_->check_subcaption) {
|
||||
setEnabled(extra_->input_subcaption,
|
||||
fl_get_button(extra_->check_subcaption));
|
||||
|
||||
} else if (ob == file_->button_edit) {
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
controller().editGraphics();
|
||||
}
|
||||
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,70 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormGraphics.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Baruch Even
|
||||
* \author Herbert Voß
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMGRAPHICS_H
|
||||
#define FORMGRAPHICS_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class CheckedPath;
|
||||
class ControlGraphics;
|
||||
struct FD_graphics;
|
||||
struct FD_graphics_file;
|
||||
struct FD_graphics_bbox;
|
||||
struct FD_graphics_extra;
|
||||
|
||||
/** This class provides an XForms implementation of the Graphics Dialog.
|
||||
*/
|
||||
class FormGraphics
|
||||
: public FormController<ControlGraphics, FormView<FD_graphics> > {
|
||||
public:
|
||||
///
|
||||
FormGraphics(Dialog &);
|
||||
private:
|
||||
|
||||
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||
that the xforms colours have been re-mapped). */
|
||||
virtual void redraw();
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
/// Update the BoundingBox info.
|
||||
void updateBB(std::string const & filename, std::string const & bb_inset);
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
// Accessor to checker owned by the button controller.
|
||||
CheckedPath * file_checker_;
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_graphics_file> file_;
|
||||
///
|
||||
boost::scoped_ptr<FD_graphics_bbox> bbox_;
|
||||
///
|
||||
boost::scoped_ptr<FD_graphics_extra> extra_;
|
||||
|
||||
/// Store the LaTeX names for the rotation origins.
|
||||
std::vector<std::string> origins_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMGRAPHICS_H
|
@ -1,199 +0,0 @@
|
||||
/**
|
||||
* \file FormInclude.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormInclude.h"
|
||||
#include "ControlInclude.h"
|
||||
#include "forms/form_include.h"
|
||||
|
||||
#include "checkedwidgets.h"
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h" // setEnabled
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyxrc.h"
|
||||
|
||||
#include "support/lstrings.h" // strip
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::rtrim;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlInclude, FormView<FD_include> > base_class;
|
||||
|
||||
FormInclude::FormInclude(Dialog & parent)
|
||||
: base_class(parent, _("Child Document")),
|
||||
file_checker_(0)
|
||||
{}
|
||||
|
||||
|
||||
void FormInclude::build()
|
||||
{
|
||||
dialog_.reset(build_include(this));
|
||||
|
||||
// Manage the ok and cancel buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_filename);
|
||||
|
||||
fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->button_browse);
|
||||
bcview().addReadOnly(dialog_->radio_useinput);
|
||||
bcview().addReadOnly(dialog_->radio_useinclude);
|
||||
bcview().addReadOnly(dialog_->radio_verbatim);
|
||||
|
||||
file_checker_ = &addCheckedPath(bcview(), true, dialog_->input_filename);
|
||||
|
||||
type_.init(dialog_->radio_useinput, ControlInclude::INPUT);
|
||||
type_.init(dialog_->radio_useinclude, ControlInclude::INCLUDE);
|
||||
type_.init(dialog_->radio_verbatim, ControlInclude::VERBATIM);
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("File name to include.");
|
||||
tooltips().init(dialog_->input_filename, str);
|
||||
str = _("Browse directories for file name.");
|
||||
tooltips().init(dialog_->button_browse, str);
|
||||
str = _("Use LaTeX \\input.");
|
||||
tooltips().init(dialog_->radio_useinput, str);
|
||||
str = _("Use LaTeX \\include.");
|
||||
tooltips().init(dialog_->radio_useinclude, str);
|
||||
str = _("Use LaTeX \\verbatiminput.");
|
||||
tooltips().init(dialog_->radio_verbatim, str);
|
||||
str = _("Underline spaces in generated output.");
|
||||
tooltips().init(dialog_->check_visiblespace, str);
|
||||
str = _("Show LaTeX preview.");
|
||||
tooltips().init(dialog_->check_preview, str);
|
||||
str = _("Load the file.");
|
||||
tooltips().init(dialog_->button_load, str);
|
||||
}
|
||||
|
||||
|
||||
void FormInclude::update()
|
||||
{
|
||||
file_checker_->setChecker(kernel().docType(), lyxrc);
|
||||
|
||||
string const filename = controller().params().getContents();
|
||||
string const cmdname = controller().params().getCmdName();
|
||||
bool const preview = static_cast<bool>((controller().params().preview()));
|
||||
|
||||
fl_set_input(dialog_->input_filename, filename.c_str());
|
||||
|
||||
bool const inputCommand = cmdname == "input";
|
||||
bool const includeCommand = cmdname == "include";
|
||||
bool const verbatimStarCommand = cmdname == "verbatiminput*";
|
||||
bool const verbatimCommand = cmdname == "verbatiminput";
|
||||
|
||||
setEnabled(dialog_->check_preview, inputCommand);
|
||||
fl_set_button(dialog_->check_preview, inputCommand ? preview : 0);
|
||||
|
||||
if (cmdname.empty())
|
||||
type_.set(ControlInclude::INPUT);
|
||||
|
||||
if (includeCommand)
|
||||
type_.set(ControlInclude::INCLUDE);
|
||||
|
||||
if (verbatimCommand || verbatimStarCommand) {
|
||||
type_.set(ControlInclude::VERBATIM);
|
||||
fl_set_button(dialog_->check_visiblespace, verbatimStarCommand);
|
||||
setEnabled(dialog_->check_visiblespace, true);
|
||||
setEnabled(dialog_->button_load, false);
|
||||
} else {
|
||||
fl_set_button(dialog_->check_visiblespace, 0);
|
||||
setEnabled(dialog_->check_visiblespace, false);
|
||||
setEnabled(dialog_->button_load, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormInclude::apply()
|
||||
{
|
||||
InsetCommandParams params = controller().params();
|
||||
|
||||
params.preview(fl_get_button(dialog_->check_preview));
|
||||
params.setContents(getString(dialog_->input_filename));
|
||||
|
||||
ControlInclude::Type const type = ControlInclude::Type(type_.get());
|
||||
if (type == ControlInclude::INPUT)
|
||||
params.setCmdName("input");
|
||||
else if (type == ControlInclude::INCLUDE)
|
||||
params.setCmdName("include");
|
||||
else if (type == ControlInclude::VERBATIM) {
|
||||
if (fl_get_button(dialog_->check_visiblespace))
|
||||
params.setCmdName("verbatiminput*");
|
||||
else
|
||||
params.setCmdName("verbatiminput");
|
||||
}
|
||||
|
||||
controller().setParams(params);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
|
||||
|
||||
if (ob == dialog_->button_browse) {
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
fl_freeze_form(form());
|
||||
ControlInclude::Type const type = ControlInclude::Type(type_.get());
|
||||
string const out_name = controller().browse(in_name, type);
|
||||
fl_set_input(dialog_->input_filename, out_name.c_str());
|
||||
fl_unfreeze_form(form());
|
||||
|
||||
} else if (ob == dialog_->button_load) {
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
|
||||
dialog().OKButton();
|
||||
controller().load(rtrim(in_name));
|
||||
action = ButtonPolicy::SMI_NOOP;
|
||||
}
|
||||
|
||||
} else if (ob == dialog_->radio_verbatim) {
|
||||
setEnabled(dialog_->check_visiblespace, true);
|
||||
setEnabled(dialog_->button_load, false);
|
||||
|
||||
} else if (ob == dialog_->radio_useinclude ||
|
||||
ob == dialog_->radio_useinput) {
|
||||
fl_set_button(dialog_->check_visiblespace, 0);
|
||||
setEnabled(dialog_->check_visiblespace, false);
|
||||
setEnabled(dialog_->button_load, true);
|
||||
|
||||
} else if (ob == dialog_->input_filename) {
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
if (rtrim(in_name).empty())
|
||||
action = ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
|
||||
if (ob == dialog_->radio_useinput) {
|
||||
setEnabled(dialog_->check_preview, true);
|
||||
} else if (ob == dialog_->radio_verbatim ||
|
||||
ob == dialog_->radio_useinclude) {
|
||||
fl_set_button(dialog_->check_preview, 0);
|
||||
setEnabled(dialog_->check_preview, false);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,53 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormInclude.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
#ifndef FORMINCLUDE_H
|
||||
#define FORMINCLUDE_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "RadioButtonGroup.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class CheckedPath;
|
||||
class ControlInclude;
|
||||
struct FD_include;
|
||||
|
||||
/** This class provides an XForms implementation of the Include Dialog.
|
||||
*/
|
||||
class FormInclude
|
||||
: public FormController<ControlInclude, FormView<FD_include> > {
|
||||
public:
|
||||
///
|
||||
FormInclude(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
// Accessor to checker owned by the button controller.
|
||||
CheckedPath * file_checker_;
|
||||
|
||||
/// include type
|
||||
RadioButtonGroup type_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMINCLUDE_H
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* \file FormLog.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormLog.h"
|
||||
#include "ControlLog.h"
|
||||
#include "forms/form_browser.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
FormLog::FormLog(Dialog & parent)
|
||||
: FormController<ControlLog, FormBrowser>(parent, "")
|
||||
{}
|
||||
|
||||
|
||||
void FormLog::update()
|
||||
{
|
||||
setTitle(controller().title());
|
||||
|
||||
std::ostringstream ss;
|
||||
controller().getContents(ss);
|
||||
|
||||
fl_clear_browser(dialog_->browser);
|
||||
fl_add_browser_line(dialog_->browser, ss.str().c_str());
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,42 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormLog.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMLOG_H
|
||||
#define FORMLOG_H
|
||||
|
||||
#include "FormBrowser.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlLog;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the LaTeX log dialog
|
||||
* for viewing the last LaTeX log file.
|
||||
*/
|
||||
class FormLog : public FormController<ControlLog, FormBrowser> {
|
||||
public:
|
||||
///
|
||||
FormLog(Dialog &);
|
||||
|
||||
// Functions accessible to the Controller.
|
||||
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply() {}
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMLOG_H
|
@ -1,193 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsBitmap.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsBitmap.h"
|
||||
|
||||
#include "bmtable.h"
|
||||
#include "forms_gettext.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "ControlMath.h"
|
||||
|
||||
|
||||
using std::max;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
extern "C" void C_FormDialogView_CancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormDialogView_InputCB(FL_OBJECT *, long);
|
||||
|
||||
FD_maths_bitmap::~FD_maths_bitmap()
|
||||
{
|
||||
if (form->visible) fl_hide_form(form);
|
||||
fl_free_form(form);
|
||||
}
|
||||
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_bitmap> > base_class;
|
||||
|
||||
|
||||
FormMathsBitmap::FormMathsBitmap(Dialog & parent, string const & t, vector<string> const & l)
|
||||
: base_class(parent, t, false),
|
||||
latex_(l), ww_(0), x_(0), y_(0), w_(0), h_(0)
|
||||
{
|
||||
ww_ = 2 * FL_abs(FL_BOUND_WIDTH);
|
||||
x_ = y_ = ww_;
|
||||
y_ += 8;
|
||||
}
|
||||
|
||||
|
||||
void FormMathsBitmap::addBitmap(BitmapStore const & bm)
|
||||
{
|
||||
bitmaps_.push_back(bm);
|
||||
|
||||
int wx = bm.bw + ww_ / 2;
|
||||
int wy = bm.bh + ww_ / 2;
|
||||
wx += (wx % bm.nx);
|
||||
wy += (wy % bm.ny);
|
||||
|
||||
if (bm.vert) {
|
||||
y_ += wy + 8;
|
||||
h_ = max(y_, h_);
|
||||
w_ = max(x_ + wx + ww_, w_);
|
||||
} else {
|
||||
x_ += wx + 8;
|
||||
w_ = max(x_, w_);
|
||||
h_ = max(y_ + wy + ww_, h_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormMathsBitmap::build()
|
||||
{
|
||||
BOOST_ASSERT(bitmaps_.size() > 0);
|
||||
|
||||
h_+= 42; // Allow room for a Close button
|
||||
|
||||
FD_maths_bitmap * fdui = new FD_maths_bitmap;
|
||||
|
||||
fdui->form = fl_bgn_form(FL_UP_BOX, w_, h_);
|
||||
fdui->form->u_vdata = this;
|
||||
|
||||
fl_add_box(FL_UP_BOX, 0, 0, w_, h_, "");
|
||||
|
||||
x_ = y_ = ww_;
|
||||
y_ += 8;
|
||||
|
||||
int y_close = 0;
|
||||
for (vector<BitmapStore>::const_iterator it = bitmaps_.begin();
|
||||
it < bitmaps_.end(); ++it) {
|
||||
FL_OBJECT * obj = buildBitmap(*it);
|
||||
|
||||
bcview().addReadOnly(obj);
|
||||
y_close = max(y_close, obj->y + obj->h);
|
||||
}
|
||||
bitmaps_.clear();
|
||||
|
||||
x_ = (fdui->form->w - 90) / 2;
|
||||
y_ = y_close + 10;
|
||||
|
||||
string const label = _("Close|^[");
|
||||
fdui->button_close = fl_add_button(FL_NORMAL_BUTTON, x_, y_, 90, 30,
|
||||
idex(label).c_str());
|
||||
fl_set_button_shortcut(fdui->button_close, scex(label).c_str(), 1);
|
||||
fl_set_object_lsize(fdui->button_close, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(fdui->button_close, C_FormDialogView_CancelCB, 0);
|
||||
|
||||
fl_end_form();
|
||||
|
||||
fdui->form->fdui = fdui;
|
||||
|
||||
dialog_.reset(fdui);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FL_OBJECT * FormMathsBitmap::buildBitmap(BitmapStore const & bmstore)
|
||||
{
|
||||
// Add a bitmap to a button panel: one bitmap per panel.
|
||||
// nt is the number of buttons and nx, ny the nr. of buttons
|
||||
// in x and y direction.
|
||||
// bw, bh and data are the bitmap dimensions width, height and
|
||||
// bit pattern; these come directly from an .xbm file included
|
||||
// as source.
|
||||
// vert indicates whether the next button panel within this
|
||||
// window will be below (true, default) or next to this one.
|
||||
//
|
||||
// The scaling of the bitmap on top of the buttons will be
|
||||
// correct if the nx, ny values are given correctly.
|
||||
int wx = bmstore.bw + ww_ / 2;
|
||||
int wy = bmstore.bh + ww_ / 2;
|
||||
wx += (wx % bmstore.nx);
|
||||
wy += (wy % bmstore.ny);
|
||||
|
||||
FL_OBJECT * obj = fl_add_bmtable(1, x_, y_, wx, wy, "");
|
||||
fl_set_object_lcol(obj, FL_BLUE);
|
||||
fl_set_object_boxtype(obj, FL_UP_BOX);
|
||||
fl_set_bmtable_data(obj, bmstore.nx, bmstore.ny, bmstore.bw, bmstore.bh,
|
||||
bmstore.data);
|
||||
fl_set_bmtable_maxitems(obj, bmstore.nt);
|
||||
fl_set_object_callback(obj, C_FormDialogView_InputCB, 0);
|
||||
|
||||
if (bmstore.vert) {
|
||||
y_ += wy + 8;
|
||||
} else {
|
||||
x_ += wx + 8;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
int FormMathsBitmap::GetIndex(FL_OBJECT * ob_in)
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
for (FL_OBJECT * ob = form()->first; ob; ob = ob->next) {
|
||||
if (ob->objclass != FL_BMTABLE)
|
||||
continue;
|
||||
|
||||
if (ob == ob_in)
|
||||
return k + fl_get_bmtable(ob);
|
||||
else
|
||||
k += fl_get_bmtable_maxitems(ob);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void FormMathsBitmap::apply()
|
||||
{
|
||||
controller().dispatchInsert(latex_chosen_);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormMathsBitmap::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
int const i = GetIndex(ob);
|
||||
|
||||
if (i < 0)
|
||||
return ButtonPolicy::SMI_INVALID;
|
||||
|
||||
latex_chosen_ = latex_[i];
|
||||
apply();
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,104 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsBitmap.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSBITMAP_H
|
||||
#define FORM_MATHSBITMAP_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
struct BitmapStore
|
||||
{
|
||||
BitmapStore(int nt_in, int nx_in, int ny_in, int bw_in, int bh_in,
|
||||
unsigned char const * data_in, bool vert_in)
|
||||
: nt(nt_in), nx(nx_in), ny(ny_in), bw(bw_in), bh(bh_in),
|
||||
data(data_in), vert(vert_in)
|
||||
{}
|
||||
|
||||
int nt;
|
||||
int nx;
|
||||
int ny;
|
||||
int bw;
|
||||
int bh;
|
||||
unsigned char const * data;
|
||||
bool vert;
|
||||
};
|
||||
|
||||
|
||||
struct FD_maths_bitmap
|
||||
{
|
||||
~FD_maths_bitmap();
|
||||
FL_FORM * form;
|
||||
FL_OBJECT * button_close;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of a maths bitmap form.
|
||||
*/
|
||||
|
||||
class ControlMath;
|
||||
|
||||
class FormMathsBitmap
|
||||
: public FormController<ControlMath, FormView<FD_maths_bitmap> > {
|
||||
public:
|
||||
///
|
||||
FormMathsBitmap(Dialog &, std::string const &, std::vector<std::string> const &);
|
||||
///
|
||||
void addBitmap(BitmapStore const &);
|
||||
|
||||
private:
|
||||
///
|
||||
int GetIndex(FL_OBJECT *);
|
||||
|
||||
///
|
||||
virtual void apply();
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Not needed.
|
||||
virtual void update() {}
|
||||
|
||||
///
|
||||
FL_OBJECT * buildBitmap(BitmapStore const & bmstore);
|
||||
|
||||
/// The latex names associated with each symbol
|
||||
std::vector<std::string> latex_;
|
||||
/// The latex name chosen
|
||||
std::string latex_chosen_;
|
||||
|
||||
/** Temporary store for bitmap data passed to addBitmap()
|
||||
* but before the FL_OBJECT is created in build().
|
||||
*/
|
||||
std::vector<BitmapStore> bitmaps_;
|
||||
|
||||
/// Border width
|
||||
int ww_;
|
||||
///
|
||||
int x_;
|
||||
///
|
||||
int y_;
|
||||
///
|
||||
int w_;
|
||||
///
|
||||
int h_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSBITMAP_H
|
@ -1,156 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsDelim.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author Pablo De Napoli
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsDelim.h"
|
||||
#include "forms/form_maths_delim.h"
|
||||
#include "ControlMath.h"
|
||||
|
||||
#include "bmtable.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/ButtonController.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
#include "delim.xbm"
|
||||
#include "delim0.xpm"
|
||||
#include "delim1.xpm"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
// FIXME: Implement fixed size delimiters (see qt3 frontend)
|
||||
|
||||
namespace {
|
||||
|
||||
int const delim_rversion[] = {
|
||||
1,1,3,3,4,5,7,7,9,9,10,11,
|
||||
3,13,15,15,16,17,19,19,20,21,22
|
||||
};
|
||||
int const delim_size =
|
||||
sizeof(delim_rversion) / sizeof(delim_rversion[0]);
|
||||
|
||||
char const * delim_values[] = {
|
||||
"(", ")", "lceil", "rceil", "uparrow", "Uparrow",
|
||||
"[", "]", "lfloor", "rfloor", "updownarrow", "Updownarrow",
|
||||
"{", "}", "/", "backslash", "downarrow", "Downarrow",
|
||||
"langle", "rangle", "|", "Vert", ".", 0
|
||||
};
|
||||
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_delim> > base_class;
|
||||
|
||||
FormMathsDelim::FormMathsDelim(Dialog & parent)
|
||||
: base_class(parent, _("Math Delimiters"), false)
|
||||
{}
|
||||
|
||||
|
||||
void FormMathsDelim::build()
|
||||
{
|
||||
dialog_.reset(build_maths_delim(this));
|
||||
|
||||
fl_set_button(dialog_->radio_left, 1);
|
||||
// Initialize button_pix to "()" as found in images/delim0.xpm:
|
||||
fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim0));
|
||||
dialog_->radio_left->u_ldata = 0;
|
||||
dialog_->radio_right->u_ldata = 1;
|
||||
//dialog_->radio_both->u_ldata = 2;
|
||||
|
||||
fl_set_bmtable_data(dialog_->bmtable, 12, 2,
|
||||
delim_width, delim_height, delim_bits);
|
||||
fl_set_bmtable_maxitems(dialog_->bmtable, 23);
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(dialog_->bmtable);
|
||||
bcview().addReadOnly(dialog_->radio_right);
|
||||
bcview().addReadOnly(dialog_->radio_left);
|
||||
bcview().addReadOnly(dialog_->radio_both);
|
||||
bcview().addReadOnly(dialog_->button_pix);
|
||||
}
|
||||
|
||||
|
||||
void FormMathsDelim::apply()
|
||||
{
|
||||
int const left = int(dialog_->radio_left->u_ldata);
|
||||
int const right = int(dialog_->radio_right->u_ldata);
|
||||
|
||||
ostringstream os;
|
||||
os << delim_values[left] << ' ' << delim_values[right];
|
||||
controller().dispatchDelim(os.str());
|
||||
}
|
||||
|
||||
|
||||
void FormMathsDelim::update()
|
||||
{
|
||||
bc().valid();
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormMathsDelim::input(FL_OBJECT *, long)
|
||||
{
|
||||
int left = int(dialog_->radio_left->u_ldata);
|
||||
int right= int(dialog_->radio_right->u_ldata);
|
||||
int const side = (fl_get_button(dialog_->radio_right) != 0);
|
||||
|
||||
int const i = fl_get_bmtable(dialog_->bmtable);
|
||||
int const button = fl_get_bmtable_numb(dialog_->bmtable);
|
||||
bool const both = (button == FL_MIDDLE_MOUSE ||
|
||||
fl_get_button(dialog_->radio_both) != 0);
|
||||
|
||||
if (i >= 0) {
|
||||
if (side || (button == FL_RIGHT_MOUSE))
|
||||
right = i;
|
||||
else {
|
||||
left = i;
|
||||
if (both) {
|
||||
right = delim_rversion[i];
|
||||
// Add left delimiter in "both" case if right one was pressed:
|
||||
for (int j = 0; j < delim_size; ++j) {
|
||||
if (delim_rversion[j] == left) {
|
||||
right = left;
|
||||
left = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-initialize button_pix to solid blue
|
||||
// (not elegant but works, MV 24.5.2002)
|
||||
fl_free_pixmap_pixmap(dialog_->button_pix);
|
||||
fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim1));
|
||||
Pixmap p1;
|
||||
fl_get_pixmap_pixmap(dialog_->button_pix, &p1, 0);
|
||||
|
||||
fl_draw_bmtable_item(dialog_->bmtable, left, p1, 0, 0);
|
||||
fl_draw_bmtable_item(dialog_->bmtable, right, p1, 16, 0);
|
||||
fl_redraw_object(dialog_->button_pix);
|
||||
|
||||
dialog_->radio_left->u_ldata = left;
|
||||
dialog_->radio_right->u_ldata = right;
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,48 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsDelim.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSDELIM_H
|
||||
#define FORM_MATHSDELIM_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlMath;
|
||||
struct FD_maths_delim;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the maths delim.
|
||||
*/
|
||||
class FormMathsDelim
|
||||
: public FormController<ControlMath, FormView<FD_maths_delim> > {
|
||||
public:
|
||||
///
|
||||
FormMathsDelim(Dialog &);
|
||||
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
///
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSDELIM_H
|
@ -1,144 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsMatrix.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author Pablo De Napoli
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsMatrix.h"
|
||||
#include "forms/form_maths_matrix.h"
|
||||
#include "ControlMath.h"
|
||||
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/ButtonController.h"
|
||||
|
||||
#include "support/lyxalgo.h" // lyx::count
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::strlen;
|
||||
#endif
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
char h_align_str[80] = "c";
|
||||
char v_align_c[] = "tcb";
|
||||
|
||||
|
||||
extern "C"
|
||||
int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
|
||||
char const * cur, int c)
|
||||
{
|
||||
BOOST_ASSERT(ob);
|
||||
FormMathsMatrix * pre =
|
||||
static_cast<FormMathsMatrix *>(ob->u_vdata);
|
||||
BOOST_ASSERT(pre);
|
||||
return pre->AlignFilter(cur, c);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_matrix> > base_class;
|
||||
|
||||
FormMathsMatrix::FormMathsMatrix(Dialog & parent)
|
||||
: base_class(parent, _("Math Matrix"), false)
|
||||
{}
|
||||
|
||||
|
||||
void FormMathsMatrix::build()
|
||||
{
|
||||
dialog_.reset(build_maths_matrix(this));
|
||||
|
||||
fl_addto_choice(dialog_->choice_valign,
|
||||
_("Top | Middle | Bottom").c_str());
|
||||
fl_set_choice(dialog_->choice_valign, 2);
|
||||
fl_set_input(dialog_->input_halign, h_align_str);
|
||||
dialog_->input_halign->u_vdata = this;
|
||||
fl_set_input_filter(dialog_->input_halign,
|
||||
C_FormMathsMatrixAlignFilter);
|
||||
setPrehandler(dialog_->input_halign);
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(dialog_->slider_rows);
|
||||
bcview().addReadOnly(dialog_->slider_columns);
|
||||
bcview().addReadOnly(dialog_->choice_valign);
|
||||
bcview().addReadOnly(dialog_->input_halign);
|
||||
}
|
||||
|
||||
|
||||
void FormMathsMatrix::apply()
|
||||
{
|
||||
char const c = v_align_c[fl_get_choice(dialog_->choice_valign) - 1];
|
||||
char const * sh = fl_get_input(dialog_->input_halign);
|
||||
int const nx = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
|
||||
int const ny = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
|
||||
|
||||
ostringstream os;
|
||||
os << nx << ' ' << ny << ' ' << c << ' ' << sh;
|
||||
controller().dispatchMatrix(os.str());
|
||||
}
|
||||
|
||||
|
||||
void FormMathsMatrix::update()
|
||||
{
|
||||
bc().valid();
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormMathsMatrix::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->choice_valign ||
|
||||
ob == dialog_->slider_rows) return ButtonPolicy::SMI_VALID;
|
||||
|
||||
int const nx = int(fl_get_slider_value(dialog_->slider_columns)+0.5);
|
||||
for (int i = 0; i < nx; ++i)
|
||||
h_align_str[i] = 'c';
|
||||
|
||||
h_align_str[nx] = '\0';
|
||||
|
||||
fl_set_input(dialog_->input_halign, h_align_str);
|
||||
fl_redraw_object(dialog_->input_halign);
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
int FormMathsMatrix::AlignFilter(char const * cur, int c)
|
||||
{
|
||||
size_t const len = strlen(cur);
|
||||
|
||||
int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5)
|
||||
- int(len)
|
||||
+ int(count(cur, cur + len, '|'));
|
||||
if (n < 0)
|
||||
return FL_INVALID;
|
||||
|
||||
if (c == 'c' || c == 'l' || c == 'r' || c == '|')
|
||||
return FL_VALID;
|
||||
|
||||
return FL_INVALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,50 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsMatrix.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSMATRIX_H
|
||||
#define FORM_MATHSMATRIX_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlMath;
|
||||
struct FD_maths_matrix;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the maths matrix.
|
||||
*/
|
||||
class FormMathsMatrix
|
||||
: public FormController<ControlMath, FormView<FD_maths_matrix> > {
|
||||
public:
|
||||
///
|
||||
FormMathsMatrix(Dialog &);
|
||||
///
|
||||
int AlignFilter(char const *, int);
|
||||
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
///
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSMATRIX_H
|
@ -1,137 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsPanel.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author Pablo De Napoli
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsPanel.h"
|
||||
#include "ControlMath.h"
|
||||
#include "forms/form_maths_panel.h"
|
||||
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include "deco.xpm"
|
||||
#include "delim.xpm"
|
||||
#include "equation.xpm"
|
||||
#include "frac-square.xpm"
|
||||
#include "matrix.xpm"
|
||||
#include "space.xpm"
|
||||
#include "style.xpm"
|
||||
#include "sqrt-square.xpm"
|
||||
#include "sub.xpm"
|
||||
#include "super.xpm"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_panel> > base_class;
|
||||
|
||||
FormMathsPanel::FormMathsPanel(Dialog & parent)
|
||||
: base_class(parent, _("Math Panel"))
|
||||
{}
|
||||
|
||||
|
||||
void FormMathsPanel::build()
|
||||
{
|
||||
dialog_.reset(build_maths_panel(this));
|
||||
|
||||
for (int i = 0; i < nr_function_names; ++i)
|
||||
fl_add_browser_line(dialog_->browser_funcs,
|
||||
function_names[i]);
|
||||
|
||||
fl_set_pixmap_data(dialog_->button_sqrt,
|
||||
const_cast<char**>(sqrt_xpm));
|
||||
fl_set_pixmap_data(dialog_->button_frac,
|
||||
const_cast<char**>(frac));
|
||||
fl_set_pixmap_data(dialog_->button_super,
|
||||
const_cast<char**>(super_xpm));
|
||||
fl_set_pixmap_data(dialog_->button_sub,
|
||||
const_cast<char**>(sub_xpm));
|
||||
fl_set_pixmap_data(dialog_->button_delim,
|
||||
const_cast<char**>(delim));
|
||||
fl_set_pixmap_data(dialog_->button_deco,
|
||||
const_cast<char**>(deco));
|
||||
fl_set_pixmap_data(dialog_->button_space,
|
||||
const_cast<char**>(space_xpm));
|
||||
fl_set_pixmap_data(dialog_->button_style,
|
||||
const_cast<char**>(style_xpm));
|
||||
fl_set_pixmap_data(dialog_->button_matrix,
|
||||
const_cast<char**>(matrix));
|
||||
fl_set_pixmap_data(dialog_->button_equation,
|
||||
const_cast<char**>(equation));
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->button_arrow) {
|
||||
controller().showDialog("matharrows");
|
||||
} else if (ob == dialog_->button_deco) {
|
||||
controller().showDialog("mathaccents");
|
||||
} else if (ob == dialog_->button_boperator) {
|
||||
controller().showDialog("mathoperators");
|
||||
} else if (ob == dialog_->button_brelats) {
|
||||
controller().showDialog("mathrelations");
|
||||
} else if (ob == dialog_->button_greek) {
|
||||
controller().showDialog("mathgreek");
|
||||
} else if (ob == dialog_->button_misc) {
|
||||
controller().showDialog("mathmisc");
|
||||
} else if (ob == dialog_->button_dots) {
|
||||
controller().showDialog("mathdots");
|
||||
} else if (ob == dialog_->button_varsize) {
|
||||
controller().showDialog("mathbigoperators");
|
||||
} else if (ob == dialog_->button_ams_misc) {
|
||||
controller().showDialog("mathamsmisc");
|
||||
} else if (ob == dialog_->button_ams_arrows) {
|
||||
controller().showDialog("mathamsarrows");
|
||||
} else if (ob == dialog_->button_ams_brel) {
|
||||
controller().showDialog("mathamsrelations");
|
||||
} else if (ob == dialog_->button_ams_nrel) {
|
||||
controller().showDialog("mathamsnegatedrelations");
|
||||
} else if (ob == dialog_->button_ams_ops) {
|
||||
controller().showDialog("mathamsoperators");
|
||||
} else if (ob == dialog_->button_delim) {
|
||||
controller().showDialog("mathdelimiter");
|
||||
} else if (ob == dialog_->button_matrix) {
|
||||
controller().showDialog("mathmatrix");
|
||||
} else if (ob == dialog_->button_space) {
|
||||
controller().showDialog("mathspace");
|
||||
} else if (ob == dialog_->button_style) {
|
||||
controller().showDialog("mathstyle");
|
||||
|
||||
} else if (ob == dialog_->button_super) {
|
||||
controller().dispatchSuperscript();
|
||||
|
||||
} else if (ob == dialog_->button_sub) {
|
||||
controller().dispatchSubscript();
|
||||
|
||||
} else if (ob == dialog_->button_equation) {
|
||||
controller().dispatchToggleDisplay();
|
||||
|
||||
} else if (ob == dialog_->button_frac) {
|
||||
controller().dispatchInsert("frac");
|
||||
|
||||
} else if (ob == dialog_->button_sqrt) {
|
||||
controller().dispatchInsert("sqrt");
|
||||
|
||||
} else if (ob == dialog_->browser_funcs) {
|
||||
int const i = fl_get_browser(dialog_->browser_funcs) - 1;
|
||||
controller().dispatchInsert(function_names[i]);
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,49 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsPanel.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSPANEL_H
|
||||
#define FORM_MATHSPANEL_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlMath;
|
||||
struct FD_maths_panel;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the maths panel.
|
||||
*/
|
||||
class FormMathsPanel
|
||||
: public FormController<ControlMath, FormView<FD_maths_panel> > {
|
||||
public:
|
||||
///
|
||||
FormMathsPanel(Dialog &);
|
||||
|
||||
private:
|
||||
/// Not needed.
|
||||
virtual void apply() {}
|
||||
///
|
||||
virtual void update() {}
|
||||
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSPANEL_H
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsSpace.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author Pablo De Napoli
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsSpace.h"
|
||||
#include "forms/form_maths_space.h"
|
||||
#include "ControlMath.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
extern char * latex_mathspace[];
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_space> > base_class;
|
||||
|
||||
FormMathsSpace::FormMathsSpace(Dialog & parent)
|
||||
: base_class(parent, _("Math Spacing"), false),
|
||||
space_(-1)
|
||||
{}
|
||||
|
||||
|
||||
void FormMathsSpace::build()
|
||||
{
|
||||
dialog_.reset(build_maths_space(this));
|
||||
|
||||
space_ = -1;
|
||||
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
bcview().addReadOnly(dialog_->button_negative);
|
||||
bcview().addReadOnly(dialog_->button_negmedspace);
|
||||
bcview().addReadOnly(dialog_->button_negthickspace);
|
||||
bcview().addReadOnly(dialog_->button_thin);
|
||||
bcview().addReadOnly(dialog_->button_medium);
|
||||
bcview().addReadOnly(dialog_->button_thick);
|
||||
bcview().addReadOnly(dialog_->button_quadratin);
|
||||
bcview().addReadOnly(dialog_->button_twoquadratin);
|
||||
}
|
||||
|
||||
|
||||
void FormMathsSpace::apply()
|
||||
{
|
||||
if (space_ >= 0)
|
||||
controller().dispatchInsert(latex_mathspace[space_]);
|
||||
}
|
||||
|
||||
ButtonPolicy::SMInput FormMathsSpace::input(FL_OBJECT *, long data)
|
||||
{
|
||||
space_ = -1;
|
||||
|
||||
if (data >= 0 && data < 8) {
|
||||
space_ = short(data);
|
||||
apply();
|
||||
}
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,51 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsSpace.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSSPACE_H
|
||||
#define FORM_MATHSSPACE_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlMath;
|
||||
struct FD_maths_space;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the maths space.
|
||||
*/
|
||||
class FormMathsSpace
|
||||
: public FormController<ControlMath, FormView<FD_maths_space> > {
|
||||
public:
|
||||
///
|
||||
FormMathsSpace(Dialog &);
|
||||
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Not needed.
|
||||
virtual void update() {}
|
||||
|
||||
/// The current choice.
|
||||
int space_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSSPACE_H
|
@ -1,106 +0,0 @@
|
||||
/**
|
||||
* \file FormMathsStyle.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author Pablo De Napoli
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
* Adapted from FormMathsSpace martin.vermeer@hut.fi
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormMathsStyle.h"
|
||||
#include "forms/form_maths_style.h"
|
||||
#include "ControlMath.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
#include "bmtable.h"
|
||||
|
||||
#include "style.xbm"
|
||||
#include "font.xbm"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
char const * latex_mathstyle[] = {
|
||||
"displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
|
||||
};
|
||||
|
||||
kb_action latex_mathfontcmds[] = {
|
||||
LFUN_FONT_BOLD, LFUN_FONT_SANS, LFUN_FONT_ROMAN, LFUN_FONT_ITAL, LFUN_FONT_CODE,
|
||||
LFUN_FONT_NOUN, LFUN_FONT_FRAK, LFUN_FONT_EMPH, LFUN_FONT_FREE_APPLY, LFUN_FONT_DEFAULT
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
typedef FormController<ControlMath, FormView<FD_maths_style> > base_class;
|
||||
|
||||
FormMathsStyle::FormMathsStyle(Dialog & parent)
|
||||
: base_class(parent, _("Math Styles & Fonts"), false),
|
||||
style_(-1)
|
||||
{}
|
||||
|
||||
|
||||
void FormMathsStyle::build()
|
||||
{
|
||||
dialog_.reset(build_maths_style(this));
|
||||
|
||||
fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
|
||||
style1_width, style1_height, style1_bits);
|
||||
fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
|
||||
bcview().addReadOnly(dialog_->bmtable_style1);
|
||||
|
||||
fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
|
||||
style2_width, style2_height, style2_bits);
|
||||
fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
|
||||
bcview().addReadOnly(dialog_->bmtable_style2);
|
||||
|
||||
fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
|
||||
font1_width, font1_height, font1_bits);
|
||||
fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
|
||||
bcview().addReadOnly(dialog_->bmtable_font1);
|
||||
|
||||
fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
|
||||
font2_width, font2_height, font2_bits);
|
||||
fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
|
||||
bcview().addReadOnly(dialog_->bmtable_font2);
|
||||
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
}
|
||||
|
||||
|
||||
void FormMathsStyle::apply()
|
||||
{
|
||||
if ((style_ >= 0) && (style_ < 4))
|
||||
controller().dispatchInsert(latex_mathstyle[style_]);
|
||||
else if ((style_ >= 4) && (style_ < 14))
|
||||
controller().dispatchFunc(latex_mathfontcmds[style_-4]);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
|
||||
{
|
||||
style_ = fl_get_bmtable(ob);
|
||||
if (style_ < 0) return ButtonPolicy::SMI_INVALID;
|
||||
|
||||
//if (ob == dialog_->bmtable_style1) style_ += 0;
|
||||
if (ob == dialog_->bmtable_style2) style_ += 1;
|
||||
if (ob == dialog_->bmtable_font1) style_ += 4;
|
||||
if (ob == dialog_->bmtable_font2) style_ += 9;
|
||||
if (data >= 12) style_ = short(data);
|
||||
apply();
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,51 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormMathsStyle.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Alejandro Aguilar Sierra
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_MATHSSTYLE_H
|
||||
#define FORM_MATHSSTYLE_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlMath;
|
||||
struct FD_maths_style;
|
||||
|
||||
/**
|
||||
* This class provides an XForms implementation of the maths style.
|
||||
*/
|
||||
class FormMathsStyle
|
||||
: public FormController<ControlMath, FormView<FD_maths_style> > {
|
||||
public:
|
||||
///
|
||||
FormMathsStyle(Dialog &);
|
||||
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
///
|
||||
virtual void build();
|
||||
///
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Not needed.
|
||||
virtual void update() {}
|
||||
|
||||
/// The current choice.
|
||||
int style_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORM_MATHSSTYLE_H
|
@ -1,90 +0,0 @@
|
||||
/**
|
||||
* \file FormNote.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormNote.h"
|
||||
#include "ControlNote.h"
|
||||
#include "forms/form_note.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "insets/insetnote.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlNote, FormView<FD_note> > base_class;
|
||||
|
||||
FormNote::FormNote(Dialog & parent)
|
||||
: base_class(parent, _("Note Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormNote::build()
|
||||
{
|
||||
dialog_.reset(build_note(this));
|
||||
|
||||
|
||||
tooltips().init(dialog_->radio_note,
|
||||
_("LyX internal only"));
|
||||
tooltips().init(dialog_->radio_comment,
|
||||
_("Export to LaTeX/Docbook but don't print"));
|
||||
tooltips().init(dialog_->radio_greyedout,
|
||||
_("Print as grey text"));
|
||||
// FIXME add Framed, Shaded
|
||||
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setCancel(dialog_->button_cancel);
|
||||
}
|
||||
|
||||
|
||||
void FormNote::update()
|
||||
{
|
||||
FL_OBJECT * rb = 0;
|
||||
|
||||
switch (controller().params().type) {
|
||||
case InsetNoteParams::Note:
|
||||
rb = dialog_->radio_note;
|
||||
break;
|
||||
case InsetNoteParams::Comment:
|
||||
rb = dialog_->radio_comment;
|
||||
break;
|
||||
case InsetNoteParams::Greyedout:
|
||||
rb = dialog_->radio_greyedout;
|
||||
break;
|
||||
// FIXME add Framed, Shaded
|
||||
}
|
||||
|
||||
fl_set_button(rb, 1);
|
||||
}
|
||||
|
||||
|
||||
void FormNote::apply()
|
||||
{
|
||||
InsetNoteParams::Type type;
|
||||
|
||||
if (fl_get_button(dialog_->radio_greyedout))
|
||||
type = InsetNoteParams::Greyedout;
|
||||
else if (fl_get_button(dialog_->radio_comment))
|
||||
type = InsetNoteParams::Comment;
|
||||
else
|
||||
type = InsetNoteParams::Note;
|
||||
|
||||
controller().params().type = type;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,41 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormNote.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMNOTE_H
|
||||
#define FORMNOTE_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlNote;
|
||||
struct FD_note;
|
||||
|
||||
/** This class provides an XForms implementation of the Note Dialog.
|
||||
*/
|
||||
class FormNote : public FormController<ControlNote, FormView<FD_note> > {
|
||||
public:
|
||||
/// Constructor
|
||||
FormNote(Dialog &);
|
||||
private:
|
||||
///
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMNOTE_H
|
@ -1,272 +0,0 @@
|
||||
/**
|
||||
* \file FormParagraph.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
* \author Rob Lahaye
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormParagraph.h"
|
||||
#include "ControlParagraph.h"
|
||||
#include "forms/form_paragraph.h"
|
||||
|
||||
#include "checkedwidgets.h"
|
||||
#include "input_validators.h"
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "controllers/helper_funcs.h"
|
||||
|
||||
#include "lyxrc.h" // to set the deafult length values
|
||||
#include "ParagraphParameters.h"
|
||||
#include "Spacing.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using boost::bind;
|
||||
|
||||
using std::remove_if;
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::contains;
|
||||
using support::getStringFromVector;
|
||||
using support::rtrim;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlParagraph, FormView<FD_paragraph> > base_class;
|
||||
|
||||
FormParagraph::FormParagraph(Dialog & parent)
|
||||
: base_class(parent, _("Paragraph Settings"))
|
||||
{}
|
||||
|
||||
|
||||
void FormParagraph::build()
|
||||
{
|
||||
// the tabbed folder
|
||||
dialog_.reset(build_paragraph(this));
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->check_noindent);
|
||||
bcview().addReadOnly(dialog_->choice_linespacing);
|
||||
bcview().addReadOnly(dialog_->input_linespacing);
|
||||
|
||||
bcview().addReadOnly(dialog_->input_labelwidth);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_linespacing);
|
||||
setPrehandler(dialog_->input_labelwidth);
|
||||
|
||||
fl_set_input_return(dialog_->input_labelwidth, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_linespacing, FL_RETURN_CHANGED);
|
||||
|
||||
// limit these inputs to unsigned floats
|
||||
fl_set_input_filter(dialog_->input_linespacing, fl_unsigned_float_filter);
|
||||
|
||||
// add alignment radio buttons
|
||||
alignment_.init(dialog_->radio_align_left, LYX_ALIGN_LEFT);
|
||||
alignment_.init(dialog_->radio_align_right, LYX_ALIGN_RIGHT);
|
||||
alignment_.init(dialog_->radio_align_block, LYX_ALIGN_BLOCK);
|
||||
alignment_.init(dialog_->radio_align_center, LYX_ALIGN_CENTER);
|
||||
|
||||
string const linespacing = _("Default|Single|OneHalf|Double|Custom");
|
||||
fl_addto_choice(dialog_->choice_linespacing, linespacing.c_str());
|
||||
|
||||
// Create the contents of the unit choices; don't include the "%" terms.
|
||||
vector<string> units_vec = getLatexUnits();
|
||||
vector<string>::iterator del =
|
||||
remove_if(units_vec.begin(), units_vec.end(),
|
||||
bind(contains<char>, _1, '%'));
|
||||
units_vec.erase(del, units_vec.end());
|
||||
}
|
||||
|
||||
|
||||
void FormParagraph::apply()
|
||||
{
|
||||
if (!form())
|
||||
return;
|
||||
|
||||
// alignment
|
||||
LyXAlignment const alignment =
|
||||
static_cast<LyXAlignment>(alignment_.get());
|
||||
controller().params().align(alignment);
|
||||
|
||||
// label width
|
||||
string const labelwidthstring =
|
||||
getString(dialog_->input_labelwidth);
|
||||
controller().params().labelWidthString(labelwidthstring);
|
||||
|
||||
// indendation
|
||||
bool const noindent = fl_get_button(dialog_->check_noindent);
|
||||
controller().params().noindent(noindent);
|
||||
|
||||
// get spacing
|
||||
Spacing::Space linespacing = Spacing::Default;
|
||||
string other;
|
||||
switch (fl_get_choice(dialog_->choice_linespacing)) {
|
||||
case 1:
|
||||
linespacing = Spacing::Default;
|
||||
break;
|
||||
case 2:
|
||||
linespacing = Spacing::Single;
|
||||
break;
|
||||
case 3:
|
||||
linespacing = Spacing::Onehalf;
|
||||
break;
|
||||
case 4:
|
||||
linespacing = Spacing::Double;
|
||||
break;
|
||||
case 5:
|
||||
// reset to default if input is empty
|
||||
other = getString(dialog_->input_linespacing);
|
||||
if (!other.empty()) {
|
||||
linespacing = Spacing::Other;
|
||||
} else {
|
||||
linespacing = Spacing::Default;
|
||||
fl_set_choice(dialog_->choice_linespacing, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Spacing const spacing(linespacing, other);
|
||||
controller().params().spacing(spacing);
|
||||
}
|
||||
|
||||
|
||||
void FormParagraph::update()
|
||||
{
|
||||
if (!dialog_.get())
|
||||
return;
|
||||
|
||||
// label width
|
||||
string const labelwidth = controller().params().labelWidthString();
|
||||
fl_set_input(dialog_->input_labelwidth, labelwidth.c_str());
|
||||
setEnabled(dialog_->input_labelwidth,
|
||||
labelwidth != _("Senseless with this layout!"));
|
||||
|
||||
// alignment
|
||||
alignment_.set(controller().params().align());
|
||||
|
||||
// mark default alignment
|
||||
LyXAlignment const default_alignment = controller().alignDefault();
|
||||
|
||||
string label = _("Block");
|
||||
if (default_alignment == LYX_ALIGN_BLOCK) {
|
||||
label += _(" (default)");
|
||||
}
|
||||
fl_set_object_label(dialog_->radio_align_block, label.c_str());
|
||||
fl_set_button_shortcut(dialog_->radio_align_block, "#B", 1);
|
||||
|
||||
label = _("Center");
|
||||
if (default_alignment == LYX_ALIGN_CENTER) {
|
||||
label += _(" (default)");
|
||||
}
|
||||
fl_set_object_label(dialog_->radio_align_center, label.c_str());
|
||||
fl_set_button_shortcut(dialog_->radio_align_center, "#C", 1);
|
||||
|
||||
label = _("Left");
|
||||
if (default_alignment == LYX_ALIGN_LEFT) {
|
||||
label += _(" (default)");
|
||||
}
|
||||
fl_set_object_label(dialog_->radio_align_left, label.c_str());
|
||||
fl_set_button_shortcut(dialog_->radio_align_left, "#L", 1);
|
||||
|
||||
label = _("Right");
|
||||
if (default_alignment == LYX_ALIGN_RIGHT) {
|
||||
label = _(" (default)");
|
||||
}
|
||||
fl_set_object_label(dialog_->radio_align_right, label.c_str());
|
||||
fl_set_button_shortcut(dialog_->radio_align_right, "#R", 1);
|
||||
|
||||
// Ensure that there's no crud left on the screen from this change
|
||||
// of labels.
|
||||
fl_redraw_form(form());
|
||||
|
||||
LyXAlignment alignpos = controller().alignPossible();
|
||||
setEnabled(dialog_->radio_align_block,
|
||||
bool(alignpos & LYX_ALIGN_BLOCK));
|
||||
setEnabled(dialog_->radio_align_center,
|
||||
bool(alignpos & LYX_ALIGN_CENTER));
|
||||
setEnabled(dialog_->radio_align_left,
|
||||
bool(alignpos & LYX_ALIGN_LEFT));
|
||||
setEnabled(dialog_->radio_align_right,
|
||||
bool(alignpos & LYX_ALIGN_RIGHT));
|
||||
|
||||
// lines, pagebreaks and indent
|
||||
fl_set_button(dialog_->check_noindent,
|
||||
controller().params().noindent());
|
||||
|
||||
// linespacing
|
||||
Spacing const space = controller().params().spacing();
|
||||
|
||||
int pos;
|
||||
switch (space.getSpace()) {
|
||||
case Spacing::Other:
|
||||
pos = 5;
|
||||
break;
|
||||
case Spacing::Double:
|
||||
pos = 4;
|
||||
break;
|
||||
case Spacing::Onehalf:
|
||||
pos = 3;
|
||||
break;
|
||||
case Spacing::Single:
|
||||
pos = 2;
|
||||
break;
|
||||
case Spacing::Default:
|
||||
default:
|
||||
pos = 1;
|
||||
break;
|
||||
}
|
||||
fl_set_choice(dialog_->choice_linespacing, pos);
|
||||
|
||||
bool const spacing_other = space.getSpace() == Spacing::Other;
|
||||
setEnabled(dialog_->input_linespacing, spacing_other);
|
||||
if (spacing_other) {
|
||||
fl_set_input(dialog_->input_linespacing,
|
||||
space.getValueAsString().c_str());
|
||||
} else {
|
||||
fl_set_input(dialog_->input_linespacing, "");
|
||||
}
|
||||
|
||||
// no indent
|
||||
fl_set_button(dialog_->check_noindent,
|
||||
controller().params().noindent());
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormParagraph::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
// Enable input when custum length is choosen,
|
||||
// disable 'keep' when no space is choosen
|
||||
if (ob == dialog_->choice_linespacing) {
|
||||
bool const custom_spacing =
|
||||
fl_get_choice(dialog_->choice_linespacing) == 5;
|
||||
setEnabled(dialog_->input_linespacing, custom_spacing);
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,49 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormParagraph.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORM_PARAGRAPH_H
|
||||
#define FORM_PARAGRAPH_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "RadioButtonGroup.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlParagraph;
|
||||
struct FD_paragraph;
|
||||
|
||||
/** This class provides an XForms implementation of the FormParagraph dialog.
|
||||
*/
|
||||
class FormParagraph
|
||||
: public FormController<ControlParagraph, FormView<FD_paragraph> > {
|
||||
public:
|
||||
///
|
||||
FormParagraph(Dialog &);
|
||||
private:
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
/// Update the dialog
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/// alignment radio buttons
|
||||
RadioButtonGroup alignment_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,62 +0,0 @@
|
||||
/**
|
||||
* \file FormPreamble.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormPreamble.h"
|
||||
#include "forms/form_preamble.h"
|
||||
|
||||
#include "controllers/ControlPreamble.h"
|
||||
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlPreamble, FormView<FD_preamble> > base_class;
|
||||
|
||||
FormPreamble::FormPreamble(Dialog & parent)
|
||||
: base_class(parent, _("LaTeX Preamble"))
|
||||
{}
|
||||
|
||||
|
||||
void FormPreamble::build()
|
||||
{
|
||||
dialog_.reset(build_preamble(this));
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_preamble);
|
||||
|
||||
// for activate ok/apply immediately upon input
|
||||
fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
void FormPreamble::apply()
|
||||
{
|
||||
controller().params(getString(dialog_->input_preamble));
|
||||
}
|
||||
|
||||
|
||||
void FormPreamble::update()
|
||||
{
|
||||
fl_set_input(dialog_->input_preamble, controller().params().c_str());
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,42 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormPreamble.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMPREAMBLE_H
|
||||
#define FORMPREAMBLE_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlPreamble;
|
||||
struct FD_preamble;
|
||||
|
||||
/** This class provides an XForms implementation of the Preamble Dialog.
|
||||
*/
|
||||
class FormPreamble
|
||||
: public FormController<ControlPreamble, FormView<FD_preamble> > {
|
||||
public:
|
||||
///
|
||||
FormPreamble(Dialog &);
|
||||
private:
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update the dialog
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMPREAMBLE_H
|
File diff suppressed because it is too large
Load Diff
@ -1,559 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormPreferences.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMPREFERENCES_H
|
||||
#define FORMPREFERENCES_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class Converters;
|
||||
class Formats;
|
||||
class Movers;
|
||||
|
||||
class Dialogs;
|
||||
class LyXRC;
|
||||
class LyXView;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlPrefs;
|
||||
struct FD_preferences;
|
||||
struct FD_preferences_colors;
|
||||
struct FD_preferences_converters;
|
||||
struct FD_preferences_copiers;
|
||||
struct FD_preferences_formats;
|
||||
struct FD_preferences_inputs_misc;
|
||||
struct FD_preferences_interface;
|
||||
struct FD_preferences_language;
|
||||
struct FD_preferences_lnf_misc;
|
||||
struct FD_preferences_identity;
|
||||
struct FD_preferences_inner_tab;
|
||||
struct FD_preferences_outputs_misc;
|
||||
struct FD_preferences_paths;
|
||||
struct FD_preferences_printer;
|
||||
struct FD_preferences_screen_fonts;
|
||||
struct FD_preferences_spelloptions;
|
||||
|
||||
class FormColorpicker;
|
||||
|
||||
/** This class provides an XForms implementation of the FormPreferences Dialog.
|
||||
* The preferences dialog allows users to set/save their preferences.
|
||||
*/
|
||||
class FormPreferences
|
||||
: public FormController<ControlPrefs, FormView<FD_preferences> > {
|
||||
public:
|
||||
FormPreferences(Dialog &);
|
||||
|
||||
private:
|
||||
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||
that the xforms colours have been re-mapped). */
|
||||
virtual void redraw();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
/// Filter the inputs -- return true if entries are valid
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// control which feedback message is output
|
||||
std::string const getFeedback(FL_OBJECT *);
|
||||
|
||||
/// Converters tabfolder
|
||||
boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
|
||||
/// import/input stuff
|
||||
boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
|
||||
/// HCI configuration
|
||||
boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
|
||||
/// Outputs tabfolder
|
||||
boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
|
||||
/// Spellchecker, language stuff, etc
|
||||
boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
|
||||
|
||||
/** Each tab folder is encapsulated in its own class.
|
||||
*/
|
||||
|
||||
class Colors {
|
||||
public:
|
||||
///
|
||||
enum GuiColors {
|
||||
GUI_COLOR_CHOICE = FL_FREE_COL15,
|
||||
GUI_COLOR_CURSOR = FL_FREE_COL16
|
||||
};
|
||||
///
|
||||
Colors(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_colors const * dialog();
|
||||
///
|
||||
void apply(); // not const as modifies modifiedXformsPrefs.
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void input(FL_OBJECT const * const);
|
||||
///
|
||||
void update() { LoadBrowserLyX(); }
|
||||
|
||||
/// Flag whether Xforms colors have changed since last file save
|
||||
bool modifiedXformsPrefs;
|
||||
|
||||
private:
|
||||
///
|
||||
void AdjustVal(int, int, double) const;
|
||||
///
|
||||
void InputBrowserLyX() const;
|
||||
///
|
||||
void LoadBrowserLyX();
|
||||
///
|
||||
void Modify();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_colors> dialog_;
|
||||
///
|
||||
boost::scoped_ptr<FormColorpicker> picker_;
|
||||
|
||||
/// A vector of LyX LColor GUI name and associated RGB color.
|
||||
std::vector<NamedColor> lyxColorDB;
|
||||
/// A vector of xforms color ID, RGB colors and associated name.
|
||||
std::vector<XformsColor> xformsColorDB;
|
||||
};
|
||||
///
|
||||
friend class Colors;
|
||||
|
||||
///
|
||||
class Converters {
|
||||
public:
|
||||
///
|
||||
Converters(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_converters const * dialog();
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update();
|
||||
///
|
||||
void UpdateBrowser();
|
||||
///
|
||||
void UpdateChoices();
|
||||
|
||||
private:
|
||||
///
|
||||
bool Add();
|
||||
///
|
||||
bool Browser();
|
||||
///
|
||||
bool erase();
|
||||
///
|
||||
bool Input();
|
||||
///
|
||||
std::string const GetFrom();
|
||||
///
|
||||
std::string const GetTo();
|
||||
///
|
||||
::Converters & converters();
|
||||
::Formats & formats();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_converters> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Converters;
|
||||
|
||||
///
|
||||
class Copiers {
|
||||
public:
|
||||
///
|
||||
Copiers(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_copiers const * dialog();
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update();
|
||||
|
||||
private:
|
||||
///
|
||||
bool Add();
|
||||
///
|
||||
bool Browser();
|
||||
///
|
||||
bool Erase();
|
||||
///
|
||||
bool Input();
|
||||
///
|
||||
::Movers & movers();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_copiers> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Copiers;
|
||||
|
||||
///
|
||||
class Formats {
|
||||
public:
|
||||
///
|
||||
Formats(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_formats const * dialog();
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update();
|
||||
|
||||
private:
|
||||
///
|
||||
bool Add();
|
||||
///
|
||||
bool Browser();
|
||||
///
|
||||
void UpdateBrowser();
|
||||
///
|
||||
bool erase();
|
||||
///
|
||||
bool Input();
|
||||
//
|
||||
::Converters & converters();
|
||||
::Formats & formats();
|
||||
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_formats> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Formats;
|
||||
|
||||
///
|
||||
class InputsMisc {
|
||||
public:
|
||||
///
|
||||
InputsMisc(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_inputs_misc const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
|
||||
};
|
||||
///
|
||||
friend class InputsMisc;
|
||||
|
||||
///
|
||||
class Interface {
|
||||
public:
|
||||
///
|
||||
Interface(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_interface const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_interface> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Interface;
|
||||
|
||||
///
|
||||
class Language {
|
||||
public:
|
||||
///
|
||||
Language(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_language const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc); // not const because calls update()
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_language> dialog_;
|
||||
///
|
||||
std::vector<std::string> lang_;
|
||||
};
|
||||
///
|
||||
friend class Language;
|
||||
|
||||
///
|
||||
class LnFmisc {
|
||||
public:
|
||||
///
|
||||
LnFmisc(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_lnf_misc const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
|
||||
};
|
||||
///
|
||||
friend class LnFmisc;
|
||||
|
||||
class Identity {
|
||||
public:
|
||||
///
|
||||
Identity(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_identity const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_identity> dialog_;
|
||||
};
|
||||
friend class Identity;
|
||||
|
||||
///
|
||||
class OutputsMisc {
|
||||
public:
|
||||
///
|
||||
OutputsMisc(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_outputs_misc const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
|
||||
};
|
||||
///
|
||||
friend class OutputsMisc;
|
||||
|
||||
///
|
||||
class Paths {
|
||||
public:
|
||||
///
|
||||
Paths(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_paths const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc);
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_paths> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Paths;
|
||||
|
||||
///
|
||||
class Printer {
|
||||
public:
|
||||
///
|
||||
Printer(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_printer const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_printer> dialog_;
|
||||
};
|
||||
///
|
||||
friend class Printer;
|
||||
|
||||
///
|
||||
class ScreenFonts {
|
||||
public:
|
||||
///
|
||||
ScreenFonts(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_screen_fonts const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc) const;
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input();
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
|
||||
};
|
||||
///
|
||||
friend class ScreenFonts;
|
||||
|
||||
///
|
||||
class SpellOptions {
|
||||
public:
|
||||
///
|
||||
SpellOptions(FormPreferences & p);
|
||||
///
|
||||
FD_preferences_spelloptions const * dialog();
|
||||
///
|
||||
void apply(LyXRC & rc); // not const because calls update()!
|
||||
///
|
||||
void build();
|
||||
///
|
||||
std::string const feedback(FL_OBJECT const * const) const;
|
||||
///
|
||||
bool input(FL_OBJECT const * const);
|
||||
///
|
||||
void update(LyXRC const & rc);
|
||||
|
||||
private:
|
||||
///
|
||||
FormPreferences & parent_;
|
||||
///
|
||||
boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
|
||||
};
|
||||
///
|
||||
friend class SpellOptions;
|
||||
|
||||
/** The tab folders.
|
||||
*/
|
||||
|
||||
///
|
||||
Colors colors_;
|
||||
///
|
||||
Converters converters_;
|
||||
///
|
||||
Copiers copiers_;
|
||||
///
|
||||
Formats formats_;
|
||||
///
|
||||
Identity identity_;
|
||||
///
|
||||
InputsMisc inputs_misc_;
|
||||
///
|
||||
Interface interface_;
|
||||
///
|
||||
Language language_;
|
||||
///
|
||||
LnFmisc lnf_misc_;
|
||||
///
|
||||
OutputsMisc outputs_misc_;
|
||||
///
|
||||
Paths paths_;
|
||||
///
|
||||
Printer printer_;
|
||||
///
|
||||
ScreenFonts screen_fonts_;
|
||||
///
|
||||
SpellOptions spelloptions_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMPREFERENCES_H
|
@ -1,259 +0,0 @@
|
||||
/**
|
||||
* \file FormPrint.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormPrint.h"
|
||||
#include "ControlPrint.h"
|
||||
#include "forms/form_print.h"
|
||||
|
||||
#include "input_validators.h"
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "PrinterParams.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlPrint, FormView<FD_print> > base_class;
|
||||
|
||||
FormPrint::FormPrint(Dialog & parent)
|
||||
: base_class(parent, _("Print Document"))
|
||||
{}
|
||||
|
||||
|
||||
void FormPrint::build()
|
||||
{
|
||||
dialog_.reset(build_print(this));
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// trigger an input event for cut&paste with middle mouse button.
|
||||
setPrehandler(dialog_->input_printer);
|
||||
setPrehandler(dialog_->input_file);
|
||||
setPrehandler(dialog_->input_from_page);
|
||||
setPrehandler(dialog_->input_to_page);
|
||||
|
||||
fl_set_input_return(dialog_->input_printer, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_file, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_from_page, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_to_page, FL_RETURN_CHANGED);
|
||||
|
||||
// limit these inputs to unsigned integers
|
||||
fl_set_input_filter(dialog_->input_from_page, fl_unsigned_int_filter);
|
||||
fl_set_input_filter(dialog_->input_to_page, fl_unsigned_int_filter);
|
||||
|
||||
// what limits (if any) make sense for these?
|
||||
fl_set_input_maxchars(dialog_->input_printer, 255);
|
||||
fl_set_input_maxchars(dialog_->input_file, 255);
|
||||
fl_set_input_maxchars(dialog_->input_from_page, 4); // 9999
|
||||
fl_set_input_maxchars(dialog_->input_to_page, 4); // 9999
|
||||
|
||||
target_.init(dialog_->radio_printer, PrinterParams::PRINTER);
|
||||
target_.init(dialog_->radio_file, PrinterParams::FILE);
|
||||
|
||||
all_pages_.init(dialog_->radio_all_pages, true);
|
||||
all_pages_.init(dialog_->radio_from_to, false);
|
||||
|
||||
// set up the tooltips for Destination
|
||||
string str = _("Select for printer output.");
|
||||
tooltips().init(dialog_->radio_printer, str);
|
||||
str = _("Enter printer command.");
|
||||
tooltips().init(dialog_->input_printer, str);
|
||||
str = _("Select for file output.");
|
||||
tooltips().init(dialog_->radio_file, str);
|
||||
str = _("Enter file name as print destination.");
|
||||
tooltips().init(dialog_->input_file, str);
|
||||
str = _("Browse directories for file name.");
|
||||
tooltips().init(dialog_->button_browse, str);
|
||||
|
||||
// set up the tooltips for Range
|
||||
str = _("Select for printing all pages.");
|
||||
tooltips().init(dialog_->radio_all_pages, str);
|
||||
str = _("Select for printing a specific page range.");
|
||||
tooltips().init(dialog_->radio_from_to, str);
|
||||
str = _("First page.");
|
||||
tooltips().init(dialog_->input_from_page, str);
|
||||
str = _("Last page.");
|
||||
tooltips().init(dialog_->input_to_page, str);
|
||||
str = _("Print the odd numbered pages.");
|
||||
tooltips().init(dialog_->check_odd_pages, str);
|
||||
str = _("Print the even numbered pages.");
|
||||
tooltips().init(dialog_->check_even_pages, str);
|
||||
|
||||
// set up the tooltips for Copies
|
||||
str = _("Number of copies to be printed.");
|
||||
tooltips().init(dialog_->counter_copies, str);
|
||||
str = _("Sort the copies.");
|
||||
tooltips().init(dialog_->check_sorted_copies, str);
|
||||
|
||||
str = _("Reverse the order of the printed pages.");
|
||||
tooltips().init(dialog_->check_reverse_order, str);
|
||||
}
|
||||
|
||||
|
||||
void FormPrint::apply()
|
||||
{
|
||||
PrinterParams pp;
|
||||
|
||||
pp.target = static_cast<PrinterParams::Target>(target_.get());
|
||||
pp.printer_name = getString(dialog_->input_printer);
|
||||
pp.file_name = getString(dialog_->input_file);
|
||||
|
||||
pp.all_pages = static_cast<bool>(all_pages_.get());
|
||||
|
||||
pp.from_page = pp.to_page = 0;
|
||||
if (!getString(dialog_->input_from_page).empty()) {
|
||||
// we have at least one page requested
|
||||
pp.from_page = convert<int>(fl_get_input(dialog_->input_from_page));
|
||||
if (!getString(dialog_->input_to_page).empty()) {
|
||||
// okay we have a range
|
||||
pp.to_page = convert<int>(fl_get_input(dialog_->input_to_page));
|
||||
} // else we only print one page.
|
||||
}
|
||||
|
||||
pp.odd_pages = static_cast<bool>(fl_get_button(dialog_->check_odd_pages));
|
||||
pp.even_pages = static_cast<bool>(fl_get_button(dialog_->check_even_pages));
|
||||
|
||||
pp.count_copies = static_cast<unsigned int>(fl_get_counter_value(dialog_->counter_copies));
|
||||
pp.sorted_copies = static_cast<bool>(fl_get_button(dialog_->check_sorted_copies));
|
||||
|
||||
pp.reverse_order = static_cast<bool>(fl_get_button(dialog_->check_reverse_order));
|
||||
|
||||
controller().params() = pp;
|
||||
}
|
||||
|
||||
|
||||
void FormPrint::update()
|
||||
{
|
||||
PrinterParams & pp = controller().params();
|
||||
|
||||
target_.set(pp.target);
|
||||
fl_set_input(dialog_->input_printer, pp.printer_name.c_str());
|
||||
fl_set_input(dialog_->input_file, pp.file_name.c_str());
|
||||
|
||||
// hmmm... maybe a bit weird but maybe not
|
||||
// we might just be remembering the last time this was printed.
|
||||
all_pages_.set(pp.all_pages);
|
||||
|
||||
string const from = ( pp.from_page ? convert<string>(pp.from_page) : string() );
|
||||
string const to = ( pp.to_page ? convert<string>(pp.to_page) : string() );
|
||||
fl_set_input(dialog_->input_from_page, from.c_str());
|
||||
fl_set_input(dialog_->input_to_page, to.c_str());
|
||||
|
||||
fl_set_button(dialog_->check_odd_pages, pp.odd_pages);
|
||||
fl_set_button(dialog_->check_even_pages, pp.even_pages);
|
||||
fl_set_button(dialog_->check_reverse_order, pp.reverse_order);
|
||||
fl_set_button(dialog_->check_sorted_copies, pp.sorted_copies);
|
||||
|
||||
fl_set_counter_value(dialog_->counter_copies, pp.count_copies);
|
||||
|
||||
// number of copies only used when output goes to printer
|
||||
bool const enable_counter = pp.target == PrinterParams::PRINTER;
|
||||
setEnabled(dialog_->counter_copies, enable_counter);
|
||||
|
||||
// sorting only used when printing more than one copy
|
||||
setEnabled(dialog_->check_sorted_copies, enable_counter && pp.count_copies > 1);
|
||||
|
||||
// reset input fields to valid input
|
||||
input(0, 0);
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormPrint::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->button_browse) {
|
||||
// Get the filename from the dialog
|
||||
string const in_name = getString(dialog_->input_file);
|
||||
string const out_name = controller().browse(in_name);
|
||||
|
||||
// Save the filename to the dialog
|
||||
if (out_name != in_name && !out_name.empty()) {
|
||||
fl_set_input(dialog_->input_file, out_name.c_str());
|
||||
}
|
||||
|
||||
// select the file radio
|
||||
if (!out_name.empty()) {
|
||||
target_.set(dialog_->radio_file);
|
||||
}
|
||||
|
||||
// if we type input string for file or printer, select that as a target
|
||||
} else if (ob == dialog_->input_file && !fl_get_button(dialog_->radio_file)) {
|
||||
target_.set(dialog_->radio_file);
|
||||
|
||||
} else if (ob == dialog_->input_printer && !fl_get_button(dialog_->radio_printer)) {
|
||||
target_.set(dialog_->radio_printer);
|
||||
|
||||
// if we type into 'from/to' fields, then select 'from/to' radio button
|
||||
} else if ((ob == dialog_->input_from_page || ob == dialog_->input_to_page) &&
|
||||
!fl_get_button(dialog_->radio_from_to)) {
|
||||
all_pages_.set(dialog_->radio_from_to);
|
||||
}
|
||||
|
||||
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
// disable OK/Apply buttons when file output is selected, but no file name entered
|
||||
if (fl_get_button(dialog_->radio_file) && getString(dialog_->input_file).empty()) {
|
||||
activate = ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
|
||||
// check 'from' and 'to' fields only when 'from/to' radio button is selected
|
||||
if (fl_get_button(dialog_->radio_from_to)) {
|
||||
char const * from = fl_get_input(dialog_->input_from_page);
|
||||
char const * to = fl_get_input(dialog_->input_to_page);
|
||||
bool const from_input = static_cast<bool>(*from);
|
||||
bool const to_input = static_cast<bool>(*to);
|
||||
|
||||
setEnabled(dialog_->input_to_page, from_input);
|
||||
if (!from_input || (to_input && convert<int>(from) > convert<int>(to))) {
|
||||
// Invalid input. Either 'from' is empty, or 'from' > 'to'.
|
||||
// Probably editting these fields, so deactivate OK/Apply until input is valid again.
|
||||
activate = ButtonPolicy::SMI_INVALID;
|
||||
} else if (!to_input || convert<int>(from) == convert<int>(to)) {
|
||||
// Valid input. Either there's only 'from' input, or 'from' == 'to'.
|
||||
// Deactivate OK/Apply if odd/even selection implies no pages.
|
||||
bool const odd_pages = static_cast<bool>(fl_get_button(dialog_->check_odd_pages));
|
||||
bool const even_pages = static_cast<bool>(fl_get_button(dialog_->check_even_pages));
|
||||
bool const odd_only = odd_pages && !even_pages;
|
||||
bool const even_only = even_pages && !odd_pages;
|
||||
bool const from_is_odd = static_cast<bool>(convert<int>(from) % 2);
|
||||
if ( (from_is_odd && even_only) || (!from_is_odd && odd_only) ) {
|
||||
activate = ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// number of copies only used when output goes to printer
|
||||
bool const enable_counter = static_cast<bool>(fl_get_button(dialog_->radio_printer));
|
||||
setEnabled(dialog_->counter_copies, enable_counter);
|
||||
|
||||
// sorting only used when printing more than one copy
|
||||
bool const enable_sorted = enable_counter && fl_get_counter_value(dialog_->counter_copies) > 1;
|
||||
setEnabled(dialog_->check_sorted_copies, enable_sorted);
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,53 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormPrint.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMPRINT_H
|
||||
#define FORMPRINT_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
#include "RadioButtonGroup.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlPrint;
|
||||
struct FD_print;
|
||||
|
||||
/** This class provides an XForms implementation of the FormPrint Dialog.
|
||||
The print dialog allows users to print their documents.
|
||||
*/
|
||||
class FormPrint
|
||||
: public FormController<ControlPrint, FormView<FD_print> > {
|
||||
public:
|
||||
///
|
||||
FormPrint(Dialog &);
|
||||
private:
|
||||
/// Apply from dialog
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/// print target
|
||||
RadioButtonGroup target_;
|
||||
/// all pages or from/to
|
||||
RadioButtonGroup all_pages_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMPRINT_H
|
@ -1,297 +0,0 @@
|
||||
/**
|
||||
* \file FormRef.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormRef.h"
|
||||
#include "ControlRef.h"
|
||||
#include "forms/form_ref.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "insets/insetref.h"
|
||||
|
||||
#include "support/lstrings.h" // trim
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::find;
|
||||
using std::max;
|
||||
using std::sort;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::getStringFromVector;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlRef, FormView<FD_ref> > base_class;
|
||||
|
||||
FormRef::FormRef(Dialog & parent)
|
||||
: base_class(parent, _("Cross-reference")),
|
||||
at_ref_(false)
|
||||
{}
|
||||
|
||||
|
||||
void FormRef::build()
|
||||
{
|
||||
dialog_.reset(build_ref(this));
|
||||
|
||||
for (int i = 0; !InsetRef::types[i].latex_name.empty(); ++i)
|
||||
fl_addto_choice(dialog_->choice_format,
|
||||
_(InsetRef::types[i].gui_name).c_str());
|
||||
|
||||
// Force the user to use the browser to change refs.
|
||||
fl_deactivate_object(dialog_->input_ref);
|
||||
|
||||
fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_ref, FL_RETURN_CHANGED);
|
||||
|
||||
setPrehandler(dialog_->input_name);
|
||||
setPrehandler(dialog_->input_ref);
|
||||
|
||||
// Manage the ok and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
bcview().setRestore(dialog_->button_restore);
|
||||
|
||||
bcview().addReadOnly(dialog_->button_update);
|
||||
bcview().addReadOnly(dialog_->input_name);
|
||||
bcview().addReadOnly(dialog_->input_ref);
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("Select a document for labels.");
|
||||
tooltips().init(dialog_->choice_document, str);
|
||||
str = _("Sort the labels alphabetically.");
|
||||
tooltips().init(dialog_->check_sort, str);
|
||||
str = _("Go to selected label.");
|
||||
tooltips().init(dialog_->button_go, str);
|
||||
str = _("Update the list of labels.");
|
||||
tooltips().init(dialog_->button_update, str);
|
||||
str = _("Select format style of the cross-reference.");
|
||||
tooltips().init(dialog_->choice_format, str);
|
||||
}
|
||||
|
||||
|
||||
void FormRef::update()
|
||||
{
|
||||
fl_set_input(dialog_->input_ref,
|
||||
controller().params().getContents().c_str());
|
||||
fl_set_input(dialog_->input_name,
|
||||
controller().params().getOptions().c_str());
|
||||
fl_set_choice(dialog_->choice_format,
|
||||
InsetRef::getType(controller().params().getCmdName()) + 1);
|
||||
|
||||
at_ref_ = false;
|
||||
switch_go_button();
|
||||
|
||||
// Name is irrelevant to LaTeX/Literate documents
|
||||
Kernel::DocType const doctype = kernel().docType();
|
||||
if (doctype == Kernel::LATEX || doctype == Kernel::LITERATE) {
|
||||
setEnabled(dialog_->input_name, false);
|
||||
} else {
|
||||
setEnabled(dialog_->input_name, true);
|
||||
}
|
||||
|
||||
// type is irrelevant to LinuxDoc/DocBook.
|
||||
if (doctype == Kernel::LINUXDOC || doctype == Kernel::DOCBOOK) {
|
||||
fl_set_choice(dialog_->choice_format, 1);
|
||||
setEnabled(dialog_->choice_format, false);
|
||||
} else {
|
||||
setEnabled(dialog_->choice_format, true);
|
||||
}
|
||||
|
||||
// Get the available buffers
|
||||
vector<string> const buffers = controller().getBufferList();
|
||||
vector<string> const choice_documents =
|
||||
getVector(dialog_->choice_document);
|
||||
|
||||
// If different from the current contents of the choice, then update it
|
||||
if (buffers != choice_documents) {
|
||||
// create a string of entries " entry1 | entry2 | entry3 "
|
||||
// with which to initialise the xforms choice object.
|
||||
string const choice =
|
||||
' ' + getStringFromVector(buffers, " | ") + ' ';
|
||||
|
||||
fl_clear_choice(dialog_->choice_document);
|
||||
fl_addto_choice(dialog_->choice_document, choice.c_str());
|
||||
}
|
||||
|
||||
fl_set_choice(dialog_->choice_document,
|
||||
controller().getBufferNum() + 1);
|
||||
|
||||
string const name = controller().
|
||||
getBufferName(fl_get_choice(dialog_->choice_document) - 1);
|
||||
refs_ = controller().getLabelList(name);
|
||||
|
||||
updateBrowser(refs_);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void updateHighlight(FL_OBJECT * browser,
|
||||
vector<string> const & keys,
|
||||
string const & ref)
|
||||
{
|
||||
vector<string>::const_iterator cit = (ref.empty())
|
||||
? keys.end()
|
||||
: find(keys.begin(), keys.end(), ref);
|
||||
|
||||
if (cit == keys.end()) {
|
||||
fl_deselect_browser(browser);
|
||||
} else {
|
||||
int const i = static_cast<int>(cit - keys.begin());
|
||||
fl_set_browser_topline(browser, max(i-5, 1));
|
||||
fl_select_browser_line(browser, i+1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void FormRef::updateBrowser(vector<string> const & akeys) const
|
||||
{
|
||||
vector<string> keys(akeys);
|
||||
if (fl_get_button(dialog_->check_sort))
|
||||
sort(keys.begin(), keys.end());
|
||||
|
||||
vector<string> browser_keys = getVector(dialog_->browser_refs);
|
||||
|
||||
if (browser_keys == keys) {
|
||||
updateHighlight(dialog_->browser_refs, keys,
|
||||
getString(dialog_->input_ref));
|
||||
return;
|
||||
}
|
||||
|
||||
fl_clear_browser(dialog_->browser_refs);
|
||||
for (vector<string>::const_iterator it = keys.begin();
|
||||
it != keys.end(); ++it)
|
||||
fl_add_browser_line(dialog_->browser_refs, it->c_str());
|
||||
|
||||
if (keys.empty()) {
|
||||
fl_add_browser_line(dialog_->browser_refs,
|
||||
_("*** No labels found in document ***").c_str());
|
||||
|
||||
setEnabled(dialog_->browser_refs, false);
|
||||
setEnabled(dialog_->check_sort, false);
|
||||
|
||||
fl_set_input(dialog_->input_ref, "");
|
||||
} else {
|
||||
setEnabled(dialog_->browser_refs, true);
|
||||
setEnabled(dialog_->check_sort, true);
|
||||
|
||||
updateHighlight(dialog_->browser_refs, keys,
|
||||
getString(dialog_->input_ref));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormRef::apply()
|
||||
{
|
||||
int const type = fl_get_choice(dialog_->choice_format) - 1;
|
||||
controller().params().setCmdName(InsetRef::getName(type));
|
||||
|
||||
controller().params().setOptions(getString(dialog_->input_name));
|
||||
controller().params().setContents(getString(dialog_->input_ref));
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormRef::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
ButtonPolicy::SMInput activate(ButtonPolicy::SMI_VALID);
|
||||
|
||||
if (ob == dialog_->button_go) {
|
||||
// goto label / go back
|
||||
|
||||
// No change to data
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
at_ref_ = !at_ref_;
|
||||
if (at_ref_) {
|
||||
controller().gotoRef(getString(dialog_->input_ref));
|
||||
} else {
|
||||
controller().gotoBookmark();
|
||||
}
|
||||
switch_go_button();
|
||||
|
||||
} else if (ob == dialog_->browser_refs) {
|
||||
|
||||
unsigned int sel = fl_get_browser(dialog_->browser_refs);
|
||||
if (sel < 1 || sel > refs_.size())
|
||||
return ButtonPolicy::SMI_NOOP;
|
||||
|
||||
if (!kernel().isBufferReadonly()) {
|
||||
string s = fl_get_browser_line(dialog_->browser_refs, sel);
|
||||
fl_set_input(dialog_->input_ref, s.c_str());
|
||||
}
|
||||
|
||||
if (at_ref_)
|
||||
controller().gotoBookmark();
|
||||
at_ref_ = false;
|
||||
switch_go_button();
|
||||
|
||||
setEnabled(dialog_->choice_format, true);
|
||||
setEnabled(dialog_->button_go, true);
|
||||
fl_set_object_lcol(dialog_->input_ref, FL_BLACK);
|
||||
|
||||
} else if (ob == dialog_->button_update ||
|
||||
ob == dialog_->check_sort ||
|
||||
ob == dialog_->choice_document) {
|
||||
|
||||
// No change to data
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
if (ob == dialog_->button_update ||
|
||||
ob == dialog_->choice_document) {
|
||||
string const name =
|
||||
controller().getBufferName(fl_get_choice(dialog_->choice_document) - 1);
|
||||
refs_ = controller().getLabelList(name);
|
||||
}
|
||||
|
||||
fl_freeze_form(form());
|
||||
updateBrowser(refs_);
|
||||
fl_unfreeze_form(form());
|
||||
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
|
||||
} else if (ob == dialog_->choice_format) {
|
||||
|
||||
int const type = fl_get_choice(dialog_->choice_format) - 1;
|
||||
if (controller().params().getCmdName() ==
|
||||
InsetRef::getName(type)) {
|
||||
activate = ButtonPolicy::SMI_NOOP;
|
||||
}
|
||||
}
|
||||
|
||||
return activate;
|
||||
}
|
||||
|
||||
|
||||
void FormRef::switch_go_button()
|
||||
{
|
||||
if (at_ref_) {
|
||||
fl_set_object_label(dialog_->button_go, _("Go back").c_str());
|
||||
tooltips().init(dialog_->button_go, _("Go back to original place.").c_str());
|
||||
} else {
|
||||
fl_set_object_label(dialog_->button_go, _("Go to").c_str());
|
||||
tooltips().init(dialog_->button_go, _("Go to selected label.").c_str());
|
||||
}
|
||||
fl_set_button_shortcut(dialog_->button_go, "#G", 1);
|
||||
fl_show_object(dialog_->button_go);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,54 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormRef.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMREF_H
|
||||
#define FORMREF_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlRef;
|
||||
struct FD_ref;
|
||||
|
||||
/** This class provides an XForms implementation of the FormRef Dialog.
|
||||
*/
|
||||
class FormRef : public FormController<ControlRef, FormView<FD_ref> > {
|
||||
public:
|
||||
///
|
||||
FormRef(Dialog &);
|
||||
private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
|
||||
///
|
||||
void updateBrowser(std::vector<std::string> const &) const;
|
||||
|
||||
///
|
||||
void switch_go_button();
|
||||
|
||||
///
|
||||
bool at_ref_;
|
||||
///
|
||||
std::vector<std::string> refs_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMREF_H
|
@ -1,110 +0,0 @@
|
||||
/**
|
||||
* \file FormSearch.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormSearch.h"
|
||||
#include "ControlSearch.h"
|
||||
#include "forms/form_search.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlSearch, FormView<FD_search> > base_class;
|
||||
|
||||
FormSearch::FormSearch(Dialog & parent)
|
||||
: base_class(parent, _("Find and Replace"))
|
||||
{}
|
||||
|
||||
|
||||
void FormSearch::build()
|
||||
{
|
||||
dialog_.reset(build_search(this));
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// disable for read-only documents
|
||||
bcview().addReadOnly(dialog_->input_replace);
|
||||
bcview().addReadOnly(dialog_->button_replace);
|
||||
bcview().addReadOnly(dialog_->button_replaceall);
|
||||
|
||||
// set up the tooltips
|
||||
string str = _("Enter the string you want to find.");
|
||||
tooltips().init(dialog_->input_search, str);
|
||||
str = _("Enter the replacement string.");
|
||||
tooltips().init(dialog_->input_replace, str);
|
||||
str = _("Continue to next search result.");
|
||||
tooltips().init(dialog_->button_findnext, str);
|
||||
str = _("Replace search result by replacement string.");
|
||||
tooltips().init(dialog_->button_replace, str);
|
||||
str = _("Replace all by replacement string.");
|
||||
tooltips().init(dialog_->button_replaceall, str);
|
||||
str = _("Do case sensitive search.");
|
||||
tooltips().init(dialog_->check_casesensitive, str);
|
||||
str = _("Search only matching words.");
|
||||
tooltips().init(dialog_->check_matchword, str);
|
||||
str = _("Search backwards.");
|
||||
tooltips().init(dialog_->check_searchbackwards, str);
|
||||
}
|
||||
|
||||
|
||||
void FormSearch::update()
|
||||
{
|
||||
fl_set_input_selected(dialog_->input_search, true);
|
||||
fl_set_focus_object(dialog_->form, dialog_->input_search);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
string const getUntrimmedString(FL_OBJECT * ob)
|
||||
{
|
||||
BOOST_ASSERT(ob->objclass == FL_INPUT);
|
||||
|
||||
char const * const tmp = fl_get_input(ob);
|
||||
return tmp ? tmp : string();
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormSearch::input(FL_OBJECT * ob, long)
|
||||
{
|
||||
if (ob == dialog_->button_findnext) {
|
||||
controller().find(getUntrimmedString(dialog_->input_search),
|
||||
fl_get_button(dialog_->check_casesensitive),
|
||||
fl_get_button(dialog_->check_matchword),
|
||||
!fl_get_button(dialog_->check_searchbackwards));
|
||||
|
||||
} else if (ob == dialog_->button_replace || ob == dialog_->button_replaceall) {
|
||||
bool const all = (ob == dialog_->button_replaceall);
|
||||
|
||||
controller().replace(getUntrimmedString(dialog_->input_search),
|
||||
getUntrimmedString(dialog_->input_replace),
|
||||
fl_get_button(dialog_->check_casesensitive),
|
||||
fl_get_button(dialog_->check_matchword),
|
||||
!fl_get_button(dialog_->check_searchbackwards),
|
||||
all);
|
||||
}
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,45 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormSearch.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef FORMSEARCH_H
|
||||
#define FORMSEARCH_H
|
||||
|
||||
#include "FormDialogView.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlSearch;
|
||||
struct FD_search;
|
||||
|
||||
/** This class provides an XForms implementation of the FormSearch Dialog.
|
||||
*/
|
||||
class FormSearch
|
||||
: public FormController<ControlSearch, FormView<FD_search> > {
|
||||
public:
|
||||
///
|
||||
FormSearch(Dialog &);
|
||||
private:
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// update the dialog
|
||||
virtual void update();
|
||||
|
||||
/// Filter the inputs
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // FORMSEARCH_H
|
@ -1,126 +0,0 @@
|
||||
/**
|
||||
* \file FormSendto.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FormSendto.h"
|
||||
#include "ControlSendto.h"
|
||||
#include "forms/form_sendto.h"
|
||||
|
||||
#include "Tooltips.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "xformsBC.h"
|
||||
|
||||
#include "format.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::trim;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
typedef FormController<ControlSendto, FormView<FD_sendto> > base_class;
|
||||
|
||||
FormSendto::FormSendto(Dialog & parent)
|
||||
: base_class(parent, _("Send Document to Command"))
|
||||
{}
|
||||
|
||||
|
||||
void FormSendto::build()
|
||||
{
|
||||
dialog_.reset(build_sendto(this));
|
||||
|
||||
fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
|
||||
setPrehandler(dialog_->input_command);
|
||||
|
||||
// Manage the ok, apply, restore and cancel/close buttons
|
||||
bcview().setOK(dialog_->button_ok);
|
||||
bcview().setApply(dialog_->button_apply);
|
||||
bcview().setCancel(dialog_->button_close);
|
||||
|
||||
// Set up the tooltip mechanism
|
||||
string str = _("Export the buffer to this format before running the command below on it.");
|
||||
tooltips().init(dialog_->browser_formats, str);
|
||||
|
||||
str = _("Run this command on the buffer exported to the chosen format. $$FName will be replaced by the name of this file.");
|
||||
tooltips().init(dialog_->input_command, str);
|
||||
}
|
||||
|
||||
|
||||
void FormSendto::update()
|
||||
{
|
||||
all_formats_ = controller().allFormats();
|
||||
|
||||
// Check whether the current contents of the browser will be
|
||||
// changed by loading the contents of formats
|
||||
vector<string> keys;
|
||||
keys.resize(all_formats_.size());
|
||||
|
||||
vector<string>::iterator result = keys.begin();
|
||||
vector<Format const *>::const_iterator it = all_formats_.begin();
|
||||
vector<Format const *>::const_iterator end = all_formats_.end();
|
||||
for (; it != end; ++it, ++result) {
|
||||
*result = (*it)->prettyname();
|
||||
}
|
||||
|
||||
vector<string> const browser_keys =
|
||||
getVector(dialog_->browser_formats);
|
||||
|
||||
if (browser_keys == keys)
|
||||
return;
|
||||
|
||||
// Reload the browser
|
||||
fl_clear_browser(dialog_->browser_formats);
|
||||
|
||||
for (vector<string>::const_iterator it = keys.begin();
|
||||
it < keys.end(); ++it) {
|
||||
fl_add_browser_line(dialog_->browser_formats, it->c_str());
|
||||
}
|
||||
|
||||
fl_set_input(dialog_->input_command, controller().getCommand().c_str());
|
||||
}
|
||||
|
||||
|
||||
ButtonPolicy::SMInput FormSendto::input(FL_OBJECT *, long)
|
||||
{
|
||||
int const line = fl_get_browser(dialog_->browser_formats);
|
||||
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
|
||||
return ButtonPolicy::SMI_INVALID;
|
||||
|
||||
string cmd = getString(dialog_->input_command);
|
||||
cmd = trim(cmd);
|
||||
if (cmd.empty())
|
||||
return ButtonPolicy::SMI_INVALID;
|
||||
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
|
||||
void FormSendto::apply()
|
||||
{
|
||||
int const line = fl_get_browser(dialog_->browser_formats);
|
||||
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
|
||||
return;
|
||||
|
||||
string const cmd = getString(dialog_->input_command);
|
||||
|
||||
controller().setFormat(all_formats_[line-1]);
|
||||
controller().setCommand(cmd);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user