@iE-mail: cfog@mech.ubc.ca
Support for two-column figure (figure*) and table (table*)
environments. Fixed minibuffer entry of floats.
+@bPanayotis "PAP" Papasotiriou
+@iE-mail: papasot@physics.upatras.gr
+ support for kluwer document class.
@bJoacim Persson
@iE-mail: sp2joap1@ida.his.se
po-file for Swedish, a tool for picking shortcuts,
src/frontends/qt2/QURL.C
src/frontends/qt2/QVCLog.C
src/frontends/qt2/lengthcombo.C
+src/frontends/xforms/Alert_pimpl.C
src/frontends/xforms/FileDialog.C
src/frontends/xforms/FormAboutlyx.C
src/frontends/xforms/FormBibitem.C
src/language.C
src/layout.C
src/lyx_cb.C
-src/lyx_gui_misc.C
src/lyx_main.C
src/lyxfind.C
src/lyxfont.C
#include "support/FileInfo.h"
#include "lyxscreen.h"
#include "support/filetools.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "LaTeX.h"
#include "BufferView_pimpl.h"
#include "insets/insetcommand.h" //ChangeRefs
FileInfo const fi(fname);
if (!fi.readable()) {
- WriteAlert(_("Error!"),
+ Alert::alert(_("Error!"),
_("Specified file is unreadable: "),
MakeDisplayPath(fname, 50));
return false;
ifstream ifs(fname.c_str());
if (!ifs) {
- WriteAlert(_("Error!"),
+ Alert::alert(_("Error!"),
_("Cannot open specified file: "),
MakeDisplayPath(fname, 50));
return false;
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
/// added for Dispatch functions
if (!label.empty()) {
//bv_->savePosition(0);
if (!bv_->gotoLabel(label))
- WriteAlert(_("Error"),
+ Alert::alert(_("Error"),
_("Couldn't find this label"),
_("in current document."));
}
+2001-11-23 John Levon <moz@compsoc.man.ac.uk>
+
+ * <various>: change to use Alert.h
+
2001-11-25 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Insert an error inset
#include "lyxtext.h"
#include "gettext.h"
#include "language.h"
-#include "lyx_gui_misc.h" // WarnReadonly()
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "encoding.h"
#include "exporter.h"
#include "Lsstream.h"
updateTitles();
users->owner()->getDialogs()->updateBufferDependent(false);
}
- if (read_only) {
- WarnReadonly(filename);
- }
}
s += tostr(unknown_layouts);
s += _(" paragraphs");
}
- WriteAlert(_("Textclass Loading Error!"), s,
+ Alert::alert(_("Textclass Loading Error!"), s,
_("When reading " + fileName()));
}
s += tostr(unknown_tokens);
s += _(" unknown tokens");
}
- WriteAlert(_("Textclass Loading Error!"), s,
+ Alert::alert(_("Textclass Loading Error!"), s,
_("When reading " + fileName()));
}
if (pp.first) {
params.textclass = pp.second;
} else {
- WriteAlert(string(_("Textclass error")),
+ Alert::alert(string(_("Textclass error")),
string(_("The document uses an unknown textclass \"")) +
lex.getString() + string("\"."),
string(_("LyX will not be able to produce output correctly.")));
params.textclass = 0;
}
if (!textclasslist.Load(params.textclass)) {
- // if the textclass wasn't loaded properly
- // we need to either substitute another
- // or stop loading the file.
- // I can substitute but I don't see how I can
- // stop loading... ideas?? ARRae980418
- WriteAlert(_("Textclass Loading Error!"),
+ // if the textclass wasn't loaded properly
+ // we need to either substitute another
+ // or stop loading the file.
+ // I can substitute but I don't see how I can
+ // stop loading... ideas?? ARRae980418
+ Alert::alert(_("Textclass Loading Error!"),
string(_("Can't load textclass ")) +
textclasslist.NameOfClass(params.textclass),
_("-- substituting default"));
// current format
} else if (file_format > LYX_FORMAT) {
// future format
- WriteAlert(_("Warning!"),
+ Alert::alert(_("Warning!"),
_("LyX file format is newer that what"),
_("is supported in this LyX version. Expect some problems."));
} else if (file_format < LYX_FORMAT) {
// old formats
if (file_format < 200) {
- WriteAlert(_("ERROR!"),
+ Alert::alert(_("ERROR!"),
_("Old LyX file format found. "
"Use LyX 0.10.x to read this!"));
return false;
if (file_format < 213)
the_end = true;
- if (!the_end)
- WriteAlert(_("Warning!"),
+ if (!the_end) {
+ Alert::alert(_("Warning!"),
_("Reading of document is not complete"),
_("Maybe the document is truncated"));
+ }
return true;
} else { // "\\lyxformat" not found
- WriteAlert(_("ERROR!"), _("Not a LyX file!"));
+ Alert::alert(_("ERROR!"), _("Not a LyX file!"));
}
} else
- WriteAlert(_("ERROR!"), _("Unable to read file!"));
+ Alert::alert(_("ERROR!"), _("Unable to read file!"));
return false;
}
lyxerr << _("Error! Document is read-only: ")
<< fname << endl;
else
- WriteAlert(_("Error! Document is read-only: "),
+ Alert::alert(_("Error! Document is read-only: "),
fname);
return false;
}
lyxerr << _("Error! Cannot write file: ")
<< fname << endl;
else
- WriteFSAlert(_("Error! Cannot write file: "),
+ Alert::err_alert(_("Error! Cannot write file: "),
fname);
return false;
}
lyxerr << _("Error! Cannot open file: ")
<< fname << endl;
else
- WriteFSAlert(_("Error! Cannot open file: "),
+ Alert::err_alert(_("Error! Cannot open file: "),
fname);
return false;
}
{
ofstream ofs(fname.c_str());
if (!ofs) {
- WriteFSAlert(_("Error: Cannot write file:"), fname);
+ Alert::err_alert(_("Error: Cannot write file:"), fname);
return;
}
writeFileAscii(ofs, linelen);
ofstream ofs(fname.c_str());
if (!ofs) {
- WriteFSAlert(_("Error: Cannot open file: "), fname);
+ Alert::err_alert(_("Error: Cannot open file: "), fname);
return;
}
ofstream ofs(fname.c_str());
if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
+ Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
{
ofstream ofs(fname.c_str());
if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
+ Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
int res = chktex.run(terr); // run chktex
if (res == -1) {
- WriteAlert(_("chktex did not work!"),
+ Alert::alert(_("chktex did not work!"),
_("Could not run with file:"), name);
} else if (res > 0) {
// Insert all errors as errors boxes
#include <algorithm>
#include <functional>
+#include "frontends/Alert.h"
#include "bufferlist.h"
#include "lyx_main.h"
#include "support/FileInfo.h"
}
+bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_list)
+{
+ bool reask = true;
+ while (reask) {
+ switch (Alert::askConfirmation(_("Changes in document:"),
+ fname,
+ _("Save document?"))) {
+ case 1: // Yes
+ // FIXME: WriteAs can be asynch !
+ if (buf->isUnnamed())
+ reask = !WriteAs(current_view, buf);
+ else {
+ reask = !MenuWrite(current_view, buf);
+ }
+ break;
+ case 2: // No
+ // if we crash after this we could
+ // have no autosave file but I guess
+ // this is really inprobable (Jug)
+ if (buf->isUnnamed()) {
+ removeAutosaveFile(buf->fileName());
+ }
+
+ unsaved_list += MakeDisplayPath(fname, 50) + "\n";
+ return true;
+ case 3: // Cancel
+ return false;
+ }
+ }
+ return false;
+}
+
+
bool BufferList::qwriteAll()
{
- bool askMoreConfirmation = false;
+ bool are_unsaved = false;
string unsaved;
for (BufferStorage::iterator it = bstore.begin();
- it != bstore.end(); ++it) {
+ it != bstore.end(); ++it) {
if (!(*it)->isLyxClean()) {
string fname;
if ((*it)->isUnnamed())
fname = OnlyFilename((*it)->fileName());
else
fname = MakeDisplayPath((*it)->fileName(), 50);
- bool reask = true;
- while (reask) {
- switch (AskConfirmation(_("Changes in document:"),
- fname,
- _("Save document?"))) {
- case 1: // Yes
- if ((*it)->isUnnamed())
- reask = !WriteAs(current_view, (*it));
- else {
- reask = !MenuWrite(current_view, (*it));
- }
- break;
- case 2: // No
- // if we crash after this we could
- // have no autosave file but I guess
- // this is really inprobable (Jug)
- if ((*it)->isUnnamed()) {
- removeAutosaveFile((*it)->fileName());
- }
- askMoreConfirmation = true;
- unsaved += MakeDisplayPath(fname, 50);
- unsaved += "\n";
- reask = false;
- break;
- case 3: // Cancel
- return false;
- }
- }
+ are_unsaved = qwriteOne(*it, fname, unsaved);
}
}
- if (askMoreConfirmation &&
- lyxrc.exit_confirmation &&
- !AskQuestion(_("Some documents were not saved:"),
- unsaved, _("Exit anyway?"))) {
- return false;
+
+ if (are_unsaved && lyxrc.exit_confirmation) {
+ return Alert::askQuestion(_("Some documents were not saved:"),
+ unsaved, _("Exit anyway?"));
}
return true;
fname = MakeDisplayPath(buf->fileName(), 50);
bool reask = true;
while (reask) {
- switch (AskConfirmation(_("Changes in document:"),
+ switch (Alert::askConfirmation(_("Changes in document:"),
fname,
_("Save document?"))){
case 1: // Yes
FileInfo fileInfo2(s);
if (!fileInfo2.exist()) {
- WriteAlert(_("Error!"), _("Cannot open file"),
+ Alert::alert(_("Error!"), _("Cannot open file"),
MakeDisplayPath(s));
return 0;
}
if (fileInfoE.exist() && fileInfo2.exist()) {
if (fileInfoE.getModificationTime()
> fileInfo2.getModificationTime()) {
- if (AskQuestion(_("An emergency save of this document exists!"),
+ if (Alert::askQuestion(_("An emergency save of this document exists!"),
MakeDisplayPath(s, 50),
_("Try to load that instead?"))) {
ts = e;
if (fileInfoA.exist() && fileInfo2.exist()) {
if (fileInfoA.getModificationTime()
> fileInfo2.getModificationTime()) {
- if (AskQuestion(_("Autosave file is newer."),
+ if (Alert::askQuestion(_("Autosave file is newer."),
MakeDisplayPath(s, 50),
_("Load that one instead?"))) {
ts = a;
}
}
if (!templateok) {
- WriteAlert(_("Error!"), _("Unable to open template"),
+ Alert::alert(_("Error!"), _("Unable to open template"),
MakeDisplayPath(tname));
// no template, start with empty buffer
b->paragraph = new Paragraph;
// file already open?
if (exists(s)) {
- if (AskQuestion(_("Document is already open:"),
+ if (Alert::askQuestion(_("Document is already open:"),
MakeDisplayPath(s, 50),
_("Do you want to reload that document?"))) {
// Reload is accomplished by closing and then loading
if (LyXVC::file_not_found_hook(s)) {
// Ask if the file should be checked out for
// viewing/editing, if so: load it.
- if (AskQuestion(_("Do you want to retrieve file under version control?"))) {
+ if (Alert::askQuestion(_("Do you want to retrieve file under version control?"))) {
// How can we know _how_ to do the checkout?
// With the current VC support it has to be,
// a RCS file since CVS do not have special ,v files.
return loadLyXFile(filename, tolastfiles);
}
}
- if (AskQuestion(_("Cannot open specified file:"),
+ if (Alert::askQuestion(_("Cannot open specified file:"),
MakeDisplayPath(s, 50),
_("Create new document with this name?")))
{
Buffer * getBuffer(unsigned int);
private:
+ /// ask to save a buffer on quit
+ bool qwriteOne(Buffer * buf, string const & fname, string & unsaved_list);
+
///
BufferStorage bstore;
#include "BufferView.h"
#include "paragraph.h"
#include "lyxfont.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "lyxtext.h"
#include "buffer.h"
#include "support/lstrings.h"
font.setLanguage(lang);
toggleAndShow(bv, font);
} else
- WriteAlert(_("Error! unknown language"),l);
+ Alert::alert(_("Error! unknown language"),l);
}
bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
if (font.language() != ignore_language ||
- font.number() != LyXFont::IGNORE)
- {
+ font.number() != LyXFont::IGNORE) {
LyXCursor & cursor = text->cursor;
text->computeBidiTables(bv->buffer(), cursor.row());
if (cursor.boundary() !=
#include "lyx_gui_misc.h"
#include "lyx_cb.h" // ShowMessage()
#include "support/lyxfunctional.h"
+#include "frontends/Alert.h"
#include "gettext.h"
#include "BufferView.h"
#include "debug.h"
format->isChildFormat())
format = getFormat(format->parentFormat());
if (!format || format->viewer().empty()) {
- WriteAlert(_("Cannot view file"),
+ Alert::alert(_("Cannot view file"),
_("No information for viewing ")
+ prettyName(format_name));
return false;
int const res = one.startscript(Systemcalls::SystemDontWait, command);
if (res) {
- WriteAlert(_("Cannot view file"),
+ Alert::alert(_("Cannot view file"),
_("Error while executing"),
command.substr(0, 50));
return false;
EdgePath edgepath = getPath(from_format, to_format);
if (edgepath.empty()) {
- WriteAlert(_("Cannot convert file"),
+ Alert::alert(_("Cannot convert file"),
_("No information for converting from ")
+ formats.prettyName(from_format) + _(" to ")
+ formats.prettyName(to_format));
if (res) {
if (conv.to == "program")
- WriteAlert(_("There were errors during the Build process."),
+ Alert::alert(_("There were errors during the Build process."),
_("You should try to fix them."));
else
- WriteAlert(_("Cannot convert file"),
+ Alert::alert(_("Cannot convert file"),
"Error while executing",
command.substr(0, 50));
return false;
string to = subst(conv.result_dir,
token_base, to_base);
if (!lyx::rename(from, to)) {
- WriteAlert(_("Error while trying to move directory:"),
+ Alert::alert(_("Error while trying to move directory:"),
from, ("to ") + to);
return false;
}
? lyx::copy(from2, to2)
: lyx::rename(from2, to2);
if (!moved && no_errors) {
- WriteAlert(_("Error while trying to move file:"),
+ Alert::alert(_("Error while trying to move file:"),
from2, _("to ") + to2);
no_errors = false;
}
}
string head;
split(command, head, ' ');
- WriteAlert(_("There were errors during running of ") + head,
+ Alert::alert(_("There were errors during running of ") + head,
s, t);
return false;
} else if (result & LaTeX::NO_OUTPUT) {
string const s = _("The operation resulted in");
string const t = _("an empty file.");
- WriteAlert(_("Resulting file is empty"), s, t);
+ Alert::alert(_("Resulting file is empty"), s, t);
return false;
}
return true;
// check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) {
- WriteAlert(_("LaTeX did not work!"),
+ Alert::alert(_("LaTeX did not work!"),
_("Missing log file:"), name);
} else if ((result & LaTeX::ERRORS)) {
int num_errors = latex.getNumErrors();
s += _(" errors detected.");
t = _("You should try to fix them.");
}
- WriteAlert(_("There were errors during the LaTeX run."),
+ Alert::alert(_("There were errors during the LaTeX run."),
s, t);
} else if (result & LaTeX::NO_OUTPUT) {
string const s = _("The operation resulted in");
string const t = _("an empty file.");
- WriteAlert(_("Resulting file is empty"), s, t);
+ Alert::alert(_("Resulting file is empty"), s, t);
}
if (bv)
#include "support/filetools.h"
#include "lyxrc.h"
#include "converter.h"
-#include "lyx_gui_misc.h" //WriteAlert
+#include "frontends/Alert.h"
#include "gettext.h"
using std::vector;
}
}
if (backend_format.empty()) {
- WriteAlert(_("Cannot export file"),
+ Alert::alert(_("Cannot export file"),
_("No information for exporting to ")
+ formats.prettyName(format));
return false;
else if (backend_format == format)
buffer->makeLaTeXFile(filename, string(), true);
else if (contains(buffer->filepath, ' ')) {
- WriteAlert(_("Cannot run latex."),
+ Alert::alert(_("Cannot run latex."),
_("The path to the lyx file cannot contain spaces."));
return false;
} else
#include <config.h>
#include "lyx_gui_misc.h"
#include "gettext.h"
+#include "frontends/xforms/xforms_helpers.h"
/* Form definition file generated with fdesign. */
--- /dev/null
+/**
+ * \file Alert.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#include <cerrno>
+
+#include "debug.h"
+#include "lyxrc.h"
+
+#include "Alert_pimpl.h"
+
+using std::endl;
+
+namespace Alert {
+
+ void alert(string const & s1, string const & s2, string const & s3) {
+ if (!lyxrc.use_gui) {
+ lyxerr << "----------------------------------------" << endl
+ << s1 << endl << s2 << endl << s3 << endl
+ << "----------------------------------------" << endl;
+ } else {
+ alert_pimpl(s1, s2, s3);
+ }
+ }
+
+ void err_alert(string const & s1, string const & s2) {
+ alert(s1, s2, strerror(errno));
+ }
+
+ bool askQuestion(string const & s1, string const & s2, string const & s3, bool default_value) {
+ if (!lyxrc.use_gui) {
+ lyxerr << "----------------------------------------" << endl
+ << s1 << endl;
+ if (!s2.empty())
+ lyxerr << s2 << endl;
+ if (!s3.empty())
+ lyxerr << s3 << endl;
+ lyxerr << "Assuming answer is "
+ << (default_value ? "yes" : "no")
+ << endl
+ << "----------------------------------------" << endl;
+ return default_value;
+ } else {
+ return askQuestion_pimpl(s1, s2, s3);
+ }
+ }
+
+ int askConfirmation(string const & s1, string const & s2, string const & s3, int default_value) {
+ if (!lyxrc.use_gui) {
+ lyxerr << "----------------------------------------" << endl
+ << s1 << endl;
+ if (!s2.empty())
+ lyxerr << s2 << endl;
+ if (!s3.empty())
+ lyxerr << s3 << endl;
+ lyxerr << "Assuming answer is ";
+ if (default_value == 1)
+ lyxerr << "yes";
+ else if (default_value == 2)
+ lyxerr << "no";
+ else
+ lyxerr << "cancel";
+ lyxerr << endl
+ << "----------------------------------------" << endl;
+ return default_value;
+ } else {
+ return askConfirmation_pimpl(s1, s2, s3);
+ }
+ }
+
+ std::pair<bool, string> const askForText(string const & msg, string const & dflt) {
+ if (!lyxrc.use_gui) {
+ lyxerr << "----------------------------------------" << endl
+ << msg << endl
+ << "Assuming answer is " << dflt
+ << "----------------------------------------" << endl;
+ return std::make_pair<bool, string>(true, dflt);
+ } else {
+ return askForText_pimpl(msg, dflt);
+ }
+ }
+}
--- /dev/null
+/**
+ * \file Alert.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include "support/lstrings.h"
+#include <algorithm>
+
+namespace Alert {
+ /// show an alert message
+ void alert(string const & s1, string const & s2 = string(),
+ string const & s3 = string());
+
+ /// show an alert message and strerror(errno)
+ void err_alert(string const & s1, string const & s2 = string());
+
+ /// ask a question
+ bool askQuestion(string const & s1, string const & s2 = string(),
+ string const & s3 = string(), bool default_value = true);
+
+ /// Returns 1 for yes, 2 for no, 3 for cancel.
+ int askConfirmation(string const & s1, string const & s2 = string(),
+ string const & s3 = string(), int default_value = 1);
+
+ /// Asks for a text
+ std::pair<bool, string> const askForText(string const & msg,
+ string const & dflt = string());
+};
--- /dev/null
+/**
+ * \file Alert_pimpl.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include "debug.h"
+
+// GUI-specific implementations
+void alert_pimpl(string const & s1, string const & s2, string const & s3);
+bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3);
+int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3);
+std::pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt);
+2001-11-22 John Levon <moz@compsoc.man.ac.uk>
+
+ * Makefile.am:
+ * Alert.h:
+ * Alert.C:
+ * Alert_pimpl.h: alerts etc.
+
2001-10-09 Herbert Voss <voss@perce.de>
* Dialogs.h: added showFile and showTexinfo signals.
/// The current visual depth
static
int x11VisualDepth();
+ /// the server's DPI estimate
+ static
+ float getScreenDPI();
};
#endif
controllers/libcontrollers.la
libfrontends_la_SOURCES=\
+ Alert.C \
+ Alert.h \
+ Alert_pimpl.h \
Dialogs.C \
Dialogs.h \
DialogBase.h \
#include "support/filetools.h"
#include "support/lstrings.h"
#include "frontends/FileDialog.h"
-#include "lyx_gui_misc.h" // WriteAlert
+#include "frontends/Alert.h"
#include "gettext.h"
#include "BufferView.h"
contains(p, "~") ||
contains(p, "$") ||
contains(p, "%")) {
- WriteAlert(_("Filename can't contain any "
+ Alert::alert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("'#', '~', '$' or '%'."));
#include "PrinterParams.h"
#include "Liason.h"
#include "helper_funcs.h" // browseFile
-#include "lyx_gui_misc.h" // WriteAlert
+#include "frontends/Alert.h"
#include "gettext.h"
#include "BufferView.h"
#include "support/LAssert.h"
view().apply();
if (!printBuffer(lv_.buffer(), params())) {
- WriteAlert(_("Error:"),
+ Alert::alert(_("Error:"),
_("Unable to print"),
_("Check that your parameters are correct"));
}
//path to texhash through system
Systemcalls one(Systemcalls::System,"texhash");
p.pop();
-// WriteAlert(_("texhash run!"),
+// Alert::alert(_("texhash run!"),
// _("rebuilding of the TeX-tree could only be successfull"),
// _("if you have had user-write-permissions to the tex-dir."));
}
#include "support/filetools.h" // OnlyPath, OnlyFilename
#include "support/lstrings.h"
#include "gettext.h" // _()
-#include "lyx_gui_misc.h" // WriteAlert
+#include "frontends/Alert.h"
using std::pair;
using std::vector;
if (result.second.find_first_of("#~$% ") == string::npos)
break;
- WriteAlert(_("Filename can't contain any "
+ Alert::alert(_("Filename can't contain any "
"of these characters:"),
_("space, '#', '~', '$' or '%'."));
}
copies_unsorted_->get_active(),
copies_count_->get_value_as_int())))
{
- WriteAlert(_("Error:"),
+ Alert::alert(_("Error:"),
_("Unable to print"),
_("Check that your parameters are correct"));
}
}
+float GUIRunTime::getScreenDPI()
+{
+ Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
+ return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
+ (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
+}
+
+
void GUIRunTime::setDefaults()
{
FL_IOPT cntl;
s += tostr(ret);
s += _(" paragraphs couldn't be converted");
}
- WriteAlert(_("Conversion Errors!"),s,
+ Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class"));
}
params.textclass = new_class;
} else {
// problem changing class -- warn user and retain old style
- WriteAlert(_("Conversion Errors!"),
+ Alert::alert(_("Conversion Errors!"),
_("Errors loading new document class."),
_("Reverting to original document class."));
dialog_->docClassCO->setCurrentItem( params.textclass );
BufferParams params = lv_->buffer()->params;
if (params.textclass != tc
- && AskQuestion(_("Should I set some parameters to"),
+ && Alert::askQuestion(_("Should I set some parameters to"),
_("the defaults of this document class?"))) {
params.textclass = tc;
params.useClassDefaults();
}
} else {
// unable to load new style
- WriteAlert(_("Conversion Errors!"),
+ Alert::alert(_("Conversion Errors!"),
_("Unable to switch to new document class."),
_("Reverting to original document class."));
combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
--- /dev/null
+/**
+ * \file Alert_pimpl.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
+#include <algorithm>
+
+#include <gettext.h>
+#include "xforms_helpers.h"
+
+#include "Alert.h"
+#include "Alert_pimpl.h"
+
+using std::pair;
+using std::make_pair;
+
+void alert_pimpl(string const & s1, string const & s2, string const & s3)
+{
+ fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
+ fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
+}
+
+
+bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
+{
+ fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
+ fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
+ return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
+}
+
+
+int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
+{
+ fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
+ scex(_("No|Nn#n")),
+ scex(_("Cancel|^[")));
+ return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(),
+ 3, idex(_("Yes|Yy#y")),
+ idex(_("No|Nn#n")),
+ idex(_("Cancel|^[")), 3);
+}
+
+
+pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
+{
+ fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
+ fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
+ fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
+ 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());
+}
+2001-11-23 John Levon <moz@compsoc.man.ac.uk>
+
+ * Makefile.am:
+ * Alert_pimpl.C: Alert etc.
+
+ * xforms_helpers.h:
+ * xforms_helpers.C:
+ * forms/fdfix.sh: move idex etc. to here
+
+ * GUIRunTime.C: move getScreenDPI() to here
+
2001-11-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* forms/form_ref.fd, form_preferences.fd, form_citation.fd,
#pragma implementation
#endif
-#include "lyx_gui_misc.h"
-
+#include "Alert.h"
+
#include "FormDocument.h"
#include "form_document.h"
#include "Dialogs.h"
*/
bool saveParamsAsDefault(BufferParams const ¶ms)
{
- if (!AskQuestion(_("Do you want to save the current settings"),
+ if (!Alert::askQuestion(_("Do you want to save the current settings"),
_("for the document layout as default?"),
_("(they will be valid for any new document)")))
return false;
s += tostr(ret);
s += _(" paragraphs couldn't be converted");
}
- WriteAlert(_("Conversion Errors!"),s,
+ Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class"));
}
} else {
// problem changing class -- warn user and retain old style
- WriteAlert(_("Conversion Errors!"),
+ Alert::alert(_("Conversion Errors!"),
_("Errors loading new document class."),
_("Reverting to original document class."));
combo_doc_class->select(int(old_class) + 1);
}
} else {
// unable to load new style
- WriteAlert(_("Conversion Errors!"),
+ Alert::alert(_("Conversion Errors!"),
_("Unable to switch to new document class."),
_("Reverting to original document class."));
combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
using std::max;
using std::sort;
-#include "lyx_gui_misc.h" // for WriteFSAlert
+#include "frontends/Alert.h"
#include "support/FileInfo.h"
#include "support/lyxlib.h"
#include "support/lstrings.h"
// Opens directory
DIR * pDirectory = ::opendir(pszDirectory.c_str());
if (!pDirectory) {
- WriteFSAlert(_("Warning! Couldn't open directory."),
+ Alert::err_alert(_("Warning! Couldn't open directory."),
pszDirectory);
pszDirectory = lyx::getcwd();
pDirectory = ::opendir(pszDirectory.c_str());
// must check the directory exists
DIR * pDirectory = ::opendir(tmp.c_str());
if (!pDirectory) {
- WriteFSAlert(_("Warning! Couldn't open directory."), tmp);
+ Alert::err_alert(_("Warning! Couldn't open directory."), tmp);
} else {
::closedir(pDirectory);
pszDirectory = tmp;
#include "LyXView.h"
#include "bmtable.h"
#include "debug.h"
-#include "lyx_gui_misc.h" // scex, idex
+#include "xforms_helpers.h"
#include "gettext.h"
#include "support/LAssert.h"
#include "debug.h"
#include "support/filetools.h"
#include "support/LAssert.h"
-#include "lyx_gui_misc.h" // idex, scex
#include "lyxlex.h"
#include "input_validators.h"
#include "xforms_helpers.h"
{
return fl_get_visual_depth();
}
+
+float GUIRunTime::getScreenDPI()
+{
+ Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
+ return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
+ (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
+}
ETAGS_ARGS = --lang=c++
# Alphabetical order please. It makes it easier to figure out what's missing.
libxforms_la_SOURCES = \
+ Alert_pimpl.C \
bmtable.c \
bmtable.h \
Color.C \
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
#include "bmtable.h"
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
#include "bmtable.h"
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
#include "bmtable.h"
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
-#include "lyx_gui_misc.h"
+#include "xforms_helpers.h"
#include "gettext.h"
/* Form definition file generated with fdesign. */
# Modify .c file for use by LyX
echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT
echo "#include <config.h>" >> $COUT
-echo "#include \"lyx_gui_misc.h\"" >> $COUT
+echo "#include \"xforms_helpers.h\"" >> $COUT
echo "#include \"gettext.h\"" >> $COUT
grep bmtable $CIN > /dev/null
piece = strip(piece) ;
piece = frontStrip(piece) ;
if (!stringOnlyContains (piece, "0123456789-")) {
- WriteAlert(_("ERROR! Unable to print!"),
+ Alert::alert(_("ERROR! Unable to print!"),
_("Check 'range of pages'!"));
return;
}
using std::pair;
using std::vector;
+// Extract shortcut from <ident>|<shortcut> string
+char const * flyx_shortcut_extract(char const * sc)
+{
+ // Find '|' in the sc and return the string after that.
+ register char const * sd = sc;
+ while(sd[0]!= 0 && sd[0] != '|') ++sd;
+
+ if (sd[0] == '|') {
+ ++sd;
+ //lyxerr << sd << endl;
+ return sd;
+ }
+ return "";
+}
+
+
+// Extract identifier from <ident>|<shortcut> string
+char const * flyx_ident_extract(char const * sc)
+{
+ register char const * se = sc;
+ while(se[0]!= 0 && se[0] != '|') ++se;
+
+ if (se[0] == 0) return sc;
+
+ char * sb = new char[se - sc + 1];
+ int index = 0;
+ register char const * sd = sc;
+ while (sd != se) {
+ sb[index] = sd[0];
+ ++index; ++sd;
+ }
+ sb[index] = 0;
+ return sb;
+}
+
+
// Set an FL_OBJECT to activated or deactivated
void setEnabled(FL_OBJECT * ob, bool enable)
{
#pragma interface
#endif
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
#include "Color.h"
+#include "support/lstrings.h"
+
+#include <vector>
+
+/// Extract shortcut from <ident>|<shortcut> string
+char const * flyx_shortcut_extract(char const * sc);
+/// Shortcut for flyx_shortcut_extract
+#define scex flyx_shortcut_extract
+
+/// Extract shortcut from <ident>|<shortcut> string
+char const * flyx_ident_extract(char const * sc);
+/// Shortcut for flyx_ident_extract
+#define idex flyx_ident_extract
/// Set an FL_OBJECT to activated or deactivated
void setEnabled(FL_OBJECT *, bool enable);
#include "bufferlist.h"
#include "support/filetools.h"
-#include "lyx_gui_misc.h" //WriteAlert
+#include "frontends/Alert.h"
#include "gettext.h"
#include "BufferView.h"
}
}
if (loader_format.empty()) {
- WriteAlert(_("Cannot import file"),
+ Alert::alert(_("Cannot import file"),
_("No information for importing from ")
+ formats.prettyName(format));
return false;
+2001-11-23 John Levon <moz@compsoc.man.ac.uk>
+
+ * various: update for Alert.h
+
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
* inset.h: fix comment
#include "lyxrc.h"
#include "gettext.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
+#include "frontends/Alert.h"
#include "support/FileInfo.h"
#include "support/lyxlib.h"
#include "support/os.h"
}
-void InsetFig::edit(BufferView * bv, int, int, unsigned int)
+void InsetFig::edit(BufferView *, int, int, unsigned int)
{
lyxerr[Debug::INFO] << "Editing InsetFig." << endl;
regenerate();
- // We should have RO-versions of the form instead.
- // The actual prevention of altering a readonly doc
- // is done in CallbackFig()
- if (bv->buffer()->isReadonly())
- WarnReadonly(bv->buffer()->fileName());
-
if (!form) {
form = create_form_Figure();
fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
if (contains(p, "#") || contains(p, "~") || contains(p, "$")
|| contains(p, "%") || contains(p, " ")) {
- WriteAlert(_("Filename can't contain any "
+ Alert::alert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("space, '#', '~', '$' or '%'."));
#include "LyXView.h"
#include "lyxtext.h"
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "debug.h"
using std::ostream;
// if selectall is activated then the fontchange was an outside general
// fontchange and this messages is not needed
if (!selectall)
- WriteAlert(_("Impossible Operation!"),
+ Alert::alert(_("Impossible Operation!"),
_("Not permitted to change font-types inside ERT-insets!"),
_("Sorry."));
}
#include "insetlabel.h"
#include "support/LOstream.h"
-#include "lyx_gui_misc.h" //askForText
+#include "frontends/Alert.h"
#include "support/lstrings.h" //frontStrip, strip
#include "lyxtext.h"
#include "buffer.h"
void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
{
- if (bv->buffer()->isReadonly()) {
- WarnReadonly(bv->buffer()->fileName());
- return;
- }
-
- pair<bool, string> result = askForText(_("Enter label:"), getContents());
+ pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
if (result.first) {
string new_contents = frontStrip(strip(result.second));
if (!new_contents.empty() &&
#include "LyXView.h"
#include "insets/insettext.h"
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "debug.h"
#include "WorkArea.h"
#include "gettext.h"
case LyXTabular::MULTICOLUMN:
{
if (sel_row_start != sel_row_end) {
- WriteAlert(_("Impossible Operation!"),
+ Alert::alert(_("Impossible Operation!"),
_("Multicolumns can only be horizontally."),
_("Sorry."));
return;
#include "layout.h"
#include "LaTeXFeatures.h"
#include "Painter.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "lyxtext.h"
#include "lyxcursor.h"
#include "CutAndPaste.h"
if (!autoBreakRows) {
if (CutAndPaste::nrOfParagraphs() > 1) {
- WriteAlert(_("Impossible operation"),
+ Alert::alert(_("Impossible operation"),
_("Cannot include more than one paragraph!"),
_("Sorry."));
break;
#include "layout.h"
#include "lyxlex.h"
#include "support/filetools.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "debug.h"
#include "gettext.h"
#include "support/LAssert.h"
"textclass file `" << MakeDisplayPath(real_file, 1000)
<< "'. Exiting." << endl;
- WriteAlert(_("LyX wasn't able to find its layout descriptions!"),
+ Alert::alert(_("LyX wasn't able to find its layout descriptions!"),
_("Check that the file \"textclass.lst\""),
_("is installed correctly. Sorry, has to exit :-("));
return false;
if (classlist.empty()) {
lyxerr << "LyXTextClassList::Read: no textclasses found!"
<< endl;
- WriteAlert(_("LyX wasn't able to find any layout description!"),
+ Alert::alert(_("LyX wasn't able to find any layout description!"),
_("Check the contents of the file \"textclass.lst\""),
_("Sorry, has to exit :-("));
return false;
#include <iostream>
#include "lyx_cb.h"
-#include "lyx_gui_misc.h"
#include "lyx_main.h"
#include "buffer.h"
#include "bufferlist.h"
#include "LyXView.h"
#include "lyxrc.h"
#include "lyxtext.h"
+#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
#include "frontends/GUIRunTime.h"
#include "insets/insetlabel.h"
if (!buffer->save()) {
string const fname = buffer->fileName();
string const s = MakeAbsPath(fname);
- if (AskQuestion(_("Save failed. Rename and try again?"),
+ if (Alert::askQuestion(_("Save failed. Rename and try again?"),
MakeDisplayPath(s, 50),
_("(If not, document is not saved.)"))) {
return WriteAs(bv, buffer);
// Same name as we have already?
if (!buffer->isUnnamed() && fname == oldname) {
- if (!AskQuestion(_("Same name as document already has:"),
+ if (!Alert::askQuestion(_("Same name as document already has:"),
MakeDisplayPath(fname, 50),
_("Save anyway?")))
return false;
}
// No, but do we have another file with this name open?
else if (!buffer->isUnnamed() && bufferlist.exists(fname)) {
- if (AskQuestion(_("Another document with same name open!"),
+ if (Alert::askQuestion(_("Another document with same name open!"),
MakeDisplayPath(fname, 50),
_("Replace with current document?")))
{
} // Check whether the file exists
else {
FileInfo const myfile(fname);
- if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
+ if (myfile.isOK() && !Alert::askQuestion(_("Document already exists:"),
MakeDisplayPath(fname, 50),
_("Replace file?")))
return false;
int ret;
if (buffer->isSGML()) {
- WriteAlert(_("Chktex does not work with SGML derived documents."));
+ Alert::alert(_("Chktex does not work with SGML derived documents."));
return 0;
} else
ret = buffer->runChktex();
s += _(" warnings found.");
t = _("Use `Navigate->Error' to find them.");
}
- WriteAlert(_("Chktex run successfully"), s, t);
+ Alert::alert(_("Chktex run successfully"), s, t);
} else {
- WriteAlert(_("Error!"), _("It seems chktex does not work."));
+ Alert::alert(_("Error!"), _("It seems chktex does not work."));
}
return ret;
}
FileInfo fi(fname);
if (!fi.readable()) {
- WriteFSAlert(_("Error! Specified file is unreadable: "),
+ Alert::err_alert(_("Error! Specified file is unreadable: "),
MakeDisplayPath(fname, 50));
return;
}
ifstream ifs(fname.c_str());
if (!ifs) {
- WriteFSAlert(_("Error! Cannot open specified file: "),
+ Alert::err_alert(_("Error! Cannot open specified file: "),
MakeDisplayPath(fname, 50));
return;
}
}
pair<bool, string> result =
- askForText(_("Enter new label to insert:"), text);
+ Alert::askForText(_("Enter new label to insert:"), text);
if (result.first) {
label = frontStrip(strip(result.second));
}
p.pop();
bv->owner()->message(_("Reloading configuration..."));
lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
- WriteAlert(_("The system has been reconfigured."),
+ Alert::alert(_("The system has been reconfigured."),
_("You need to restart LyX to make use of any"),
_("updated document class specifications."));
}
#pragma implementation
#endif
-#include <cerrno>
+#include FORMS_H_LOCATION
+
#include "lyx_gui_misc.h"
-#include "BufferView.h"
-#include "buffer.h"
-#include "gettext.h"
#include "figure_form.h"
-#include "lyx_cb.h"
-#include "lyx_main.h"
#include "print_form.h"
-#include "LyXView.h"
-#include "bufferview_funcs.h"
-#include "support/filetools.h"
-#include "lyxrc.h"
-#include "debug.h"
-
-using std::pair;
-using std::make_pair;
-using std::endl;
-
-extern BufferView * current_view;
extern FD_form_figure * fd_form_figure;
extern FD_form_sendto * fd_form_sendto;
extern void HideFiguresPopups();
-
-// Prevents LyX from being killed when the close box is pressed in a popup.
+// The code below is just waiting to go away really ...
+
extern "C"
int CancelCloseBoxCB(FL_FORM *, void *)
{
return FL_CANCEL;
}
-
-// Redraw the form (on receipt of a Signal indicating, for example,
-// that the xform colors have been re-mapped).
void RedrawAllBufferRelatedDialogs()
{
if (fd_form_figure->form_figure->visible) {
}
}
-// Prevents LyX from crashing when no buffers available
-// This is also one of the functions that we _really_ dont want
-// we should try to finds way to help us with that.
-// The signal/slot mechanism can probably help.
void CloseAllBufferRelatedDialogs()
{
- // don't forget to check that dynamically created forms
- // have been created otherwise hiding one could cause a crash
- // need the visible check otherwise XForms prints a warning
- // if hiding an invisible form
if (fd_form_figure->form_figure->visible) {
fl_hide_form(fd_form_figure->form_figure);
}
HideFiguresPopups();
}
-// This is another function we really don't want.
-// Again the Signal/Slot mechanism is tailor made for this task.
void updateAllVisibleBufferRelatedDialogs(bool)
{
HideFiguresPopups();
}
-
-// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_shortcut_extract(char const * sc)
-{
- // Find '|' in the sc and return the string after that.
- register char const * sd = sc;
- while(sd[0]!= 0 && sd[0] != '|') ++sd;
-
- if (sd[0] == '|') {
- ++sd;
- //lyxerr << sd << endl;
- return sd;
- }
- return "";
-}
-
-
-// Extract identifier from <ident>|<shortcut> string
-char const * flyx_ident_extract(char const * sc)
-{
- register char const * se = sc;
- while(se[0]!= 0 && se[0] != '|') ++se;
-
- if (se[0] == 0) return sc;
-
- char * sb = new char[se - sc + 1];
- int index = 0;
- register char const * sd = sc;
- while (sd != se) {
- sb[index] = sd[0];
- ++index; ++sd;
- }
- sb[index] = 0;
- return sb;
-}
-
-
-//
-void WriteAlert(string const & s1, string const & s2, string const & s3)
-{
- LyXView * lview = 0;
- if (current_view && current_view->owner())
- lview = current_view->owner();
- if (lview) {
- /// Write to minibuffer
- lview->prohibitInput();
- string const msg = s1 + ' ' + s2 + ' ' + s3;
- lview->message(msg);
- fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
- fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
- lview->allowInput();
- } else {
- /// Write to lyxerr
- lyxerr << "----------------------------------------" << endl
- << s1 << endl << s2 << endl << s3 << endl
- << "----------------------------------------" << endl;
- }
-}
-
-
-// Alarms user of something related to files
-void WriteFSAlert(string const & s1, string const & s2)
-{
- WriteAlert(s1, s2, strerror(errno));
-}
-
-
-bool AskQuestion(string const & s1, string const & s2, string const & s3,
- bool default_value)
-{
- if (!lyxrc.use_gui) {
- lyxerr << "----------------------------------------" << endl
- << s1 << endl;
- if (!s2.empty())
- lyxerr << s2 << endl;
- if (!s3.empty())
- lyxerr << s3 << endl;
- lyxerr << "Assuming answer is "
- << (default_value ? "yes" : "no")
- << endl
- << "----------------------------------------" << endl;
- return default_value;
- }
-
- fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
- fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
- return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
-}
-
-
-// Returns 1 for yes, 2 for no, 3 for cancel.
-int AskConfirmation(string const & s1, string const & s2, string const & s3,
- int default_value)
-{
- if (!lyxrc.use_gui) {
- lyxerr << "----------------------------------------" << endl
- << s1 << endl;
- if (!s2.empty())
- lyxerr << s2 << endl;
- if (!s3.empty())
- lyxerr << s3 << endl;
- lyxerr << "Assuming answer is ";
- if (default_value == 1)
- lyxerr << "yes";
- else if (default_value == 2)
- lyxerr << "no";
- else
- lyxerr << "cancel";
- lyxerr << endl
- << "----------------------------------------" << endl;
- return default_value;
- }
-
- fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
- scex(_("No|Nn#n")),
- scex(_("Cancel|^[")));
- return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(),
- 3, idex(_("Yes|Yy#y")),
- idex(_("No|Nn#n")),
- idex(_("Cancel|^[")), 3);
-}
-
-
-// Asks for a text
-pair<bool, string> const
-askForText(string const & msg, string const & dflt)
-{
- if (!lyxrc.use_gui) {
- lyxerr << "----------------------------------------" << endl
- << msg << endl
- << "Assuming answer is " << dflt
- << "----------------------------------------" << endl;
- return make_pair<bool, string>(true, dflt);
- }
-
- fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
- fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
- fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
- 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());
-}
-
-
-// Inform the user that the buffer is read-only, and that changes in the
-// dialog box that is to appear will be ignored.
-void WarnReadonly(string const & file)
-{
- WriteAlert(_("Any changes will be ignored"),
- _("The document is read-only:"),
- MakeDisplayPath(file));
-}
-
-/// Get the dpi setting of the current screen
-float getScreenDPI()
-{
- Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display());
- return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
- (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
-}
#endif
#include FORMS_H_LOCATION
-#include "LString.h"
-#include <utility> /* needed for pair<> definition */
/// Prevents LyX from being killed when the close box is pressed in a popup.
extern "C"
/// Ensures info in visible popups are always correct.
void updateAllVisibleBufferRelatedDialogs(bool switched = false);
-/* These shortcut extractors should be shifted to frontends/xforms/ eventually */
-
-/// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_shortcut_extract(char const * sc);
-/// Shortcut for flyx_shortcut_extract
-#define scex flyx_shortcut_extract
-
-/// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_ident_extract(char const * sc);
-/// Shortcut for flyx_ident_extract
-#define idex flyx_ident_extract
-
-/// Show message
-void WriteAlert(string const & s1, string const & s2 = string(),
- string const & s3 = string());
-
-/// Alarms user of something related to files
-void WriteFSAlert(string const & s1, string const & s2 = string());
-
-/// Asks "Yes" or "No". Returns true for yes, false for no
-bool AskQuestion(string const & s1, string const & s2 = string(),
- string const & s3 = string(), bool default_value = true);
-
-/// Asks "Yes", "No" or "Cancel". Returns 1 for yes, 2 for no, 3 for cancel
-int AskConfirmation(string const & s1, string const & s2 = string(),
- string const & s3 = string(), int default_value = 1);
-
-/// returns a bool: false=cancelled, true=okay. string contains returned text
-std::pair<bool, string> const
-askForText(string const & msg,
- string const & dflt = string());
-
-/// Informs the user that changes in the coming form will be ignored
-void WarnReadonly(string const & file);
-
-/// Get the dpi setting of the current screen
-float getScreenDPI();
-
#endif
#include "lyx_gui.h"
#include "LyXView.h"
#include "lyxfunc.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
+#include "frontends/GUIRunTime.h"
#include "lyxrc.h"
#include "support/path.h"
#include "support/filetools.h"
// Calculate screen dpi as average of x-DPI and y-DPI:
if (lyxrc.use_gui) {
- lyxrc.dpi = getScreenDPI();
+ lyxrc.dpi = GUIRunTime::getScreenDPI();
lyxerr[Debug::INIT] << "DPI setting detected to be "
<< lyxrc.dpi + 0.5 << endl;
} else {
// If the user specified explicitely a directory, ask whether
// to create it (otherwise, always create it)
if (explicit_userdir &&
- !AskQuestion(_("You have specified an invalid LyX directory."),
+ !Alert::askQuestion(_("You have specified an invalid LyX directory."),
_("It is needed to keep your own configuration."),
_("Should I try to set it up for you (recommended)?"))) {
lyxerr << _("Running without personal LyX directory.") << endl;
lyxerr[Debug::INIT] << "Found " << name
<< " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) {
- WriteAlert(_("LyX Warning!"),
+ Alert::alert(_("LyX Warning!"),
_("Error while reading ") + lyxrc_path + ".",
_("Using built-in defaults."));
return false;
return gui;
}
-
-
#include "lyxtext.h"
#include "lyxfind.h"
#include "LyXView.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "support/textutils.h"
#include "support/lstrings.h"
#include "BufferView.h"
if (searchstr.length() == 0
|| (searchstr.length() == 1 && searchstr[0] == ' '))
{
- WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
+ Alert::alert(_("Sorry!"), _("You cannot replace a single space, "
"nor an empty character."));
return 0;
}
}
if (size == string::size_type(i)) {
// if necessary, check whether string matches word
- if (!mw ||
- (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
- && (pos + Paragraph::size_type(size) >= par->size()
- || !IsLetterCharOrDigit(par->getChar(pos + size))))
- ))
- {
+ if (!mw)
+ return true;
+ if ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
+ && (pos + Paragraph::size_type(size) >= par->size()
+ || !IsLetterCharOrDigit(par->getChar(pos + size)))) {
return true;
}
}
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
#include "frontends/Menubar.h"
+#include "frontends/Alert.h"
#include "FloatList.h"
#include "converter.h"
#include "exporter.h"
// Check if the document already is open
if (bufferlist.exists(s)) {
- switch (AskConfirmation(_("Document is already open:"),
+ switch (Alert::askConfirmation(_("Document is already open:"),
MakeDisplayPath(s, 50),
_("Do you want to close that document now?\n"
"('No' will just switch to the open version)")))
// Check whether the file already exists
FileInfo fi(s);
if (fi.readable() &&
- AskQuestion(_("File already exists:"),
+ Alert::askQuestion(_("File already exists:"),
MakeDisplayPath(s, 50),
_("Do you want to open the document?"))) {
// loads document
// necessary
string const fullpath = FileSearch(string(), filename, "lyx");
if (fullpath.empty()) {
- WriteAlert(_("Error"), _("Could not find file"), filename);
+ Alert::alert(_("Error"), _("Could not find file"), filename);
return;
}
// Check if the document already is open
if (bufferlist.exists(lyxfile)) {
- switch (AskConfirmation(_("Document is already open:"),
+ switch (Alert::askConfirmation(_("Document is already open:"),
MakeDisplayPath(lyxfile, 50),
_("Do you want to close that document now?\n"
"('No' will just switch to the open version)")))
// Check if a LyX document by the same root exists in filesystem
FileInfo const f(lyxfile, true);
- if (f.exist() && !AskQuestion(_("A document by the name"),
+ if (f.exist() && !Alert::askQuestion(_("A document by the name"),
MakeDisplayPath(lyxfile),
_("already exists. Overwrite?"))) {
owner->message(_("Canceled"));
#include <unistd.h>
+#include "frontends/Alert.h"
#include "lyxvc.h"
#include "vc-backend.h"
#include "debug.h"
// If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() &&
- AskQuestion(_("Changes in document:"),
+ Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) {
vcs->owner()->getUser()->owner()
lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
pair<bool, string> tmp =
- askForText(_("LyX VC: Initial description"),
+ Alert::askForText(_("LyX VC: Initial description"),
_("(no initial description)"));
if (!tmp.first || tmp.second.empty()) {
// should we insist on checking tmp.second.empty()?
lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
- WriteAlert(_("Info"),
+ Alert::alert(_("Info"),
_("This document has NOT been registered."));
return;
}
{
// If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() &&
- AskQuestion(_("Changes in document:"),
+ Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) {
vcs->owner()->getUser()->owner()
}
lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
- pair<bool, string> tmp = askForText(_("LyX VC: Log Message"));
+ pair<bool, string> tmp = Alert::askForText(_("LyX VC: Log Message"));
if (tmp.first) {
if (tmp.second.empty()) {
tmp.second = _("(no log message)");
{
lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
if (!vcs->owner()->isLyxClean()
- && !AskQuestion(_("Changes in document:"),
+ && !Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Ignore changes and proceed with check out?"))) {
return;
// Here we should check if the buffer is dirty. And if it is
// we should warn the user that reverting will discard all
// changes made since the last check in.
- if (AskQuestion(_("When you revert, you will loose all changes made"),
+ if (Alert::askQuestion(_("When you revert, you will loose all changes made"),
_("to the document since the last check in."),
_("Do you still want to do it?"))) {
#include "BufferView.h"
#include "gettext.h"
#include "debug.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "support/LOstream.h"
#include "support/LAssert.h"
#include "support/lyxlib.h"
string const default_label =
(lyxrc.label_init_length >= 0) ? "eq:" : "";
pair<bool, string> const res = old_label.empty()
- ? askForText(_("Enter new label to insert:"), default_label)
- : askForText(_("Enter label:"), old_label);
+ ? Alert::askForText(_("Enter new label to insert:"), default_label)
+ : Alert::askForText(_("Enter label:"), old_label);
lyxerr << "res: " << res.first << " - '" << res.second << "'\n";
if (!res.first)
#include <config.h>
#include "lyx_gui_misc.h"
#include "gettext.h"
+#include "frontends/xforms/xforms_helpers.h"
/* Form definition file generated with fdesign. */
#endif
#include <cstdlib>
+#include <cstdio>
#include <fcntl.h>
#include <cerrno>
#include "debug.h"
#include "filetools.h"
#include "LSubstring.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "FileInfo.h"
#include "support/path.h" // I know it's OS/2 specific (SMiyata)
#include "gettext.h"
// directory_iterator dit(path);
// directory_iterator dend;
// if (dit == dend) {
- // WriteFSAlert(_("Error! Cannot open directory:"), path);
+ // Alert::err_alert(_("Error! Cannot open directory:"), path);
// return -1;
// }
// for (; dit != dend; ++dit) {
// continue;
// string unlinkpath(AddName(path, filename));
// if (lyx::unlink(unlinkpath))
- // WriteFSAlert(_("Error! Could not remove file:"),
+ // Alert::err_alert(_("Error! Could not remove file:"),
// unlinkpath);
// }
// return 0;
DIR * dir = ::opendir(path.c_str());
if (!dir) {
- WriteFSAlert (_("Error! Cannot open directory:"), path);
+ Alert::err_alert (_("Error! Cannot open directory:"), path);
return -1;
}
struct dirent * de;
deleted = (DeleteAllFilesInDir(unlinkpath) == 0);
deleted &= (lyx::unlink(unlinkpath) == 0);
if (!deleted) {
- WriteFSAlert (_("Error! Could not remove file:"),
- unlinkpath);
+ Alert::err_alert(_("Error! Could not remove file:"),
+ unlinkpath);
return_value = -1;
}
}
lyx::unlink(tmpfl.c_str());
if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) {
- WriteFSAlert(_("Error! Couldn't create temporary directory:"),
+ Alert::err_alert(_("Error! Couldn't create temporary directory:"),
tempdir);
return string();
}
return -1;
}
if (lyx::rmdir(tmpdir)) {
- WriteFSAlert(_("Error! Couldn't delete temporary directory:"),
+ Alert::err_alert(_("Error! Couldn't delete temporary directory:"),
tmpdir);
return -1;
}
// of EMX mkstemp().
string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++);
if (lyx::mkdir(tmpfl, 0777)) {
- WriteFSAlert(_("Error! Couldn't create temporary directory:"),
+ Alert::err_alert(_("Error! Couldn't create temporary directory:"),
tmpdir);
return string();
}
string temp(strip(os::slashify_path(path), '/'));
if (temp.empty()) {
- WriteAlert(_("Internal error!"),
+ Alert::alert(_("Internal error!"),
_("Call to createDirectory with invalid name"));
return false;
}
if (lyx::mkdir(temp, permission)) {
- WriteFSAlert (_("Error! Couldn't create directory:"), temp);
+ Alert::err_alert (_("Error! Couldn't create directory:"), temp);
return false;
}
return true;
FileInfo const fileinfo(a);
if (fileinfo.exist()) {
if (lyx::unlink(a) != 0) {
- WriteFSAlert(_("Could not delete auto-save file!"), a);
+ Alert::err_alert(_("Could not delete auto-save file!"), a);
}
}
}
// throw logical_error();
// The use of WriteFSAlerrt makes this impossible
// to inline.
- //WriteFSAlert(_("Error: Dir already popped: "),
+ //Alert::err_alert(_("Error: Dir already popped: "),
// pushedDir_);
return 0;
}
if (lyx::chdir(pushedDir_)) {
// should throw an exception
// throw DirChangeError();
- // The use of WriteFSAlert makes this impossible
+ // The use of Alert::err_alert makes this impossible
// to inline.
- //WriteFSAlert(
+ //Alert::err_alert(
// _("Error: Could not change to directory: "),
// pushedDir_);
}
if (pushedDir_.empty() || lyx::chdir(path)) {
// should throw an exception
// throw DirChangeError();
- // The use of WriteFSAlert makes this
+ // The use of Alert::err_alert makes this
// impossible to inline.
- //WriteFSAlert(_("Error: Could not change to directory: "),
+ //Alert::err_alert(_("Error: Could not change to directory: "),
// path);
}
} else {
#include "debug.h"
#include "vspace.h"
#include "layout.h"
-#include "lyx_gui_misc.h"
+#include "frontends/Alert.h"
#include "buffer.h"
#include "BufferView.h"
#include "Painter.h"
void LyXTabular::DeleteRow(int row)
{
- // Why make it so hard? (Lgb)
- //if (!(rows_ - 1))
- //return;
if (rows_ == 1) return; // Not allowed to delete last row
row_info.erase(row_info.begin() + row); //&row_info[row]);
lyxerr << "Tabular format < 5 is not supported anymore\n"
"Get an older version of LyX (< 1.1.x) for conversion!"
<< endl;
- WriteAlert(_("Warning:"),
+ Alert::alert(_("Warning:"),
_("Tabular format < 5 is not supported anymore\n"),
_("Get an older version of LyX (< 1.1.x) for conversion!"));
if (version > 2) {
for (; par; par = par->next()) {
for (int i = 0; i < par->size(); ++i) {
- if (par->getChar(i) == Paragraph::META_NEWLINE)
+ if (par->getChar(i) == Paragraph::META_NEWLINE)
return BOX_PARBOX;
}
}
return BOX_NONE;
}
-
-/* Emacs:
- * Local variables:
- * tab-width: 4
- * End:
- * vi:set tabstop=4:
- */