// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+ * Copyright 1995-2000 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#include "print_form.h"
#include "sp_form.h"
#include "insets/insetindex.h"
+#include "LyXView.h"
+#include "bufferview_funcs.h"
+#include "support/filetools.h"
-extern MiniBuffer *minibuffer;
-extern BufferView *current_view;
+using std::pair;
+using std::make_pair;
+
+extern BufferView * current_view;
extern FD_form_paragraph * fd_form_paragraph;
extern FD_form_paragraph_extra * fd_form_paragraph_extra;
-extern FD_form_search * fd_form_search;
extern FD_form_character * fd_form_character;
extern FD_form_document * fd_form_document;
extern FD_form_paper * fd_form_paper;
extern FD_form_quotes * fd_form_quotes;
extern FD_form_preamble * fd_form_preamble;
extern FD_form_table * fd_form_table;
-extern FD_form_print * fd_form_print;
extern FD_form_sendto * fd_form_sendto;
extern FD_form_figure * fd_form_figure;
extern FD_form_toc * fd_form_toc;
// 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 CloseAllBufferRelatedPopups()
+void CloseAllBufferRelatedDialogs()
{
// don't forget to check that dynamically created forms
// have been created otherwise hiding one could cause a crash
if (fd_form_paragraph_extra->form_paragraph_extra->visible) {
fl_hide_form(fd_form_paragraph_extra->form_paragraph_extra);
}
- if (fd_form_search->form_search->visible) {
- fl_hide_form(fd_form_search->form_search);
- }
if (fd_form_character->form_character->visible) {
fl_hide_form(fd_form_character->form_character);
}
if (fd_form_table->form_table->visible) {
fl_hide_form(fd_form_table->form_table);
}
- if (fd_form_print->form_print->visible) {
- fl_hide_form(fd_form_print->form_print);
- }
if (fd_form_figure->form_figure->visible) {
fl_hide_form(fd_form_figure->form_figure);
}
}
}
if (citation_form) {
- if (citation_form->citation_form->visible) {
- fl_hide_form(citation_form->citation_form);
+ if (citation_form->form->visible) {
+ fl_hide_form(citation_form->form);
}
}
if (bibitem_form) {
// This is another function we really don't want.
// Again the Signal/Slot mechanism is tailor made for this task.
-void updateAllVisibleBufferRelatedPopups()
+void updateAllVisibleBufferRelatedDialogs()
{
if (fd_form_document->form_document->visible) {
UpdateLayoutDocument();
}
}
if (fd_form_toc->browser_toc->visible) {
- TocUpdateCB(0,0);
+ TocUpdateCB(0, 0);
+ }
+ if (fd_latex_log->LaTeXLog->visible) {
+ LatexLogUpdate(0,0);
}
#ifdef ALWAYS_UPDATE_REF
// Ideally, the RefUpdateCB should be modified so that if the
// of course a compromise and an annoyance for users switching
// between separate documents. ARRae 241198
if (fd_form_ref->form_ref->visible) {
- RefUpdateCB(0,0);
+ RefUpdateCB(0, 0);
}
#endif
- if (current_view->currentBuffer()->isReadonly()) {
+ if (current_view->buffer()->isReadonly()) {
// a little crude perhaps but it works. ARRae
if (fd_form_character->form_character->visible) {
fl_hide_form(fd_form_character->form_character);
if (fd_form_table->form_table->visible) {
fl_hide_form(fd_form_table->form_table);
}
+
+#ifndef ALWAYS_UPDATE_REF
+ // We must update the popup in order to make the
+ // insert ref buttons insactive
+ if (fd_form_ref->form_ref->visible) {
+ RefUpdateCB(0, 0);
+ }
+#endif
+
+#ifndef ALWAYS_CLOSE_MATH_PANELS
+ // The math popups should be closed only if we switch
+ // to a readonly buffer
+ if (fd_panel) {
+ if (fd_panel->panel->visible) {
+ fl_hide_form(fd_panel->panel);
+ }
+ }
+ if (fd_delim) {
+ if (fd_delim->delim->visible) {
+ fl_hide_form(fd_delim->delim);
+ }
+ }
+ if (fd_deco) {
+ if (fd_deco->deco->visible) {
+ fl_hide_form(fd_deco->deco);
+ }
+ }
+ if (fd_space) {
+ if (fd_space->space->visible) {
+ fl_hide_form(fd_space->space);
+ }
+ }
+ if (fd_matrix) {
+ if (fd_matrix->matrix->visible) {
+ fl_hide_form(fd_matrix->matrix);
+ }
+ }
+#endif
}
// We have either changed buffers or changed the readonly status
// so the safest thing to do is hide all inset popups that
// are editting insets from the previous buffer or aren't
// allowed in readonly docs.
+#ifdef ALWAYS_CLOSE_MATH_PANELS
if (fd_panel) {
if (fd_panel->panel->visible) {
fl_hide_form(fd_panel->panel);
fl_hide_form(fd_matrix->matrix);
}
}
+#endif
if (citation_form) {
- if (citation_form->citation_form->visible) {
- fl_hide_form(citation_form->citation_form);
+ if (citation_form->form->visible) {
+ fl_hide_form(citation_form->form);
}
}
if (bibitem_form) {
}
// Extract shortcut from <ident>|<shortcut> string
-const char* flyx_shortcut_extract(const char*sc)
+char const * flyx_shortcut_extract(char const * sc)
{
// Find '|' in the sc and return the string after that.
- register const char *sd = sc;
- while(sd[0]!=0 && sd[0] != '|') sd++;
+ register char const * sd = sc;
+ while(sd[0]!= 0 && sd[0] != '|') ++sd;
- if (sd[0]=='|') {
- sd++;
+ if (sd[0] == '|') {
+ ++sd;
//lyxerr << sd << endl;
return sd;
}
return "";
}
+
// Extract identifier from <ident>|<shortcut> string
-const char* flyx_ident_extract(const char *sc)
+char const * flyx_ident_extract(char const * sc)
{
- register const char *se = sc;
- while(se[0]!=0 && se[0] != '|') se++;
+ register char const * se = sc;
+ while(se[0]!= 0 && se[0] != '|') ++se;
- if (se[0]==0) return sc;
+ if (se[0] == 0) return sc;
- char * sb = new char[se-sc + 1];
+ char * sb = new char[se - sc + 1];
int index = 0;
- register const char *sd = sc;
+ register char const * sd = sc;
while (sd != se) {
sb[index] = sd[0];
- index++; sd++;
+ ++index; ++sd;
}
- sb[index]=0;
+ sb[index] = 0;
return sb;
}
+
//
void WriteAlert(string const & s1, string const & s2, string const & s3)
{
+ MiniBuffer * minibuffer = 0;
+ if (current_view && current_view->owner())
+ minibuffer = current_view->owner()->getMiniBuffer();
if (minibuffer) {
- ProhibitInput();
+ ProhibitInput(current_view);
minibuffer->Set(s1, s2, s3);
}
fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
if (minibuffer) {
- AllowInput();
+ AllowInput(current_view);
}
}
{
fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
-#if FL_REVISION > 85
return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
-#else
- return fl_show_question(s1.c_str(), s2.c_str(), s3.c_str());
-#endif
}
+
// Returns 1 for yes, 2 for no, 3 for cancel.
int AskConfirmation(string const & s1, string const & s2, string const & s3)
{
fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
scex(_("No|Nn#n")),
scex(_("Cancel|^[")));
-#if FL_REVISION < 86
- return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(),
- 3, idex(_("Yes|Yy#y")),
- idex(_("No|Nn#n")),
- idex(_("Cancel|^[")));
-#endif
-#if FL_REVISION > 85
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);
-#endif
}
// Asks for a text
-string askForText(string const & msg, string const & dflt)
+pair<bool, string> askForText(string const & msg, string const & dflt)
{
- string tmp;
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")));
- tmp = fl_show_input(msg.c_str(), dflt.c_str());
- return tmp;
+ 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()
+void WarnReadonly(string const & file)
{
WriteAlert(_("Any changes will be ignored"),
_("The document is read-only:"),
- current_view->currentBuffer()->getFileName());
+ MakeDisplayPath(file));
}
+/// Get the dpi setting of the current screen
+float getScreenDPI()
+{
+ Screen * scr = DefaultScreenOfDisplay(fl_get_display());
+ return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
+ (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
+}