+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * ui/default.ui: use the new 'dialog-show-new-inset "name"' instead
+ of 'citation-insert', 'reference-insert' and 'bibtex-insert'.
+
2003-02-25 Angus Leeming <leeming@lyx.org>
* reLyX/BasicLyX.pm (regularizeLatexLength, getAsLyXLength):
Submenu "Math|h" "insert_math"
Separator
Submenu "Special Character|S" "insert_special"
- Item "Citation Reference...|C" "citation-insert"
- Item "Cross Reference...|R" "reference-insert"
+ Item "Citation Reference...|C" "dialog-show-new-inset citation"
+ Item "Cross Reference...|R" "dialog-show-new-inset ref"
Item "Label...|L" "label-insert"
Item "Footnote|F" "footnote-insert"
Item "Marginal Note|M" "marginalnote-insert"
Item "Table of Contents|C" "toc-insert"
FloatListInsert
Item "Index List|I" "index-print"
- Item "BibTeX Reference...|B" "bibtex-insert"
+ Item "BibTeX Reference...|B" "dialog-show-new-inset bibtex"
End
Menu "insert_file"
#include "iterators.h"
#include "lyxfind.h"
+#include "insets/insetbibitem.h"
#include "insets/insetbibtex.h"
#include "insets/insetcite.h"
+#include "insets/insetert.h"
#include "insets/insetfloatlist.h"
#include "insets/insetgraphics.h"
#include "insets/insetinclude.h"
#include "insets/insetref.h"
#include "insets/insettext.h"
#include "insets/insettoc.h"
+#include "insets/inseturl.h"
#include "mathed/formulabase.h"
MenuInsertLabel(bv_, ev.argument);
break;
- case LFUN_REF_INSERT:
- if (ev.argument.empty()) {
- InsetCommandParams p("ref");
- owner_->getDialogs().createRef(p.getAsString());
- } else {
- InsetCommandParams p;
- p.setFromString(ev.argument);
-
- InsetRef * inset = new InsetRef(p, *buffer_);
- if (!insertInset(inset))
- delete inset;
- else
- updateInset(inset, true);
- }
- break;
-
case LFUN_BOOKMARK_SAVE:
savePosition(strToUnsignedInt(ev.argument));
break;
mathDispatch(FuncRequest(bv_, ev.action, ev.argument));
break;
- case LFUN_CITATION_INSERT:
- {
- InsetCommandParams p;
- p.setFromString(ev.argument);
+ case LFUN_BIBITEM_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
- InsetCitation * inset = new InsetCitation(p);
- if (!insertInset(inset))
- delete inset;
- else {
- inset->setLoadingBuffer(bv_->buffer(), false);
- updateInset(inset, true);
+ InsetBase * base =
+ owner_->getDialogs().getOpenInset("bibitem");
+ InsetBibitem * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetBibitem *>(base);
+ if (!inset)
+ break;
+
+ if (params.getContents() !=
+ inset->params().getContents()) {
+ bv_->ChangeCitationsIfUnique(
+ inset->params().getContents(),
+ params.getContents());
+ }
+ inset->setParams(params);
+ } else {
+ inset = new InsetBibitem(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
}
+ updateInset(inset, true);
+
+ // We need to do a redraw because the maximum
+ // InsetBibitem width could have changed
+#warning please check you mean repaint() not update(),
+#warning and whether the repaint() is needed at all
+ bv_->repaint();
+ bv_->fitCursor();
+ }
+ break;
+
+ case LFUN_BIBTEX_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base =
+ owner_->getDialogs().getOpenInset("bibtex");
+ InsetBibtex * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetBibtex *>(base);
+ if (!inset)
+ break;
+ if (params.getContents() !=
+ inset->params().getContents()) {
+ bv_->ChangeCitationsIfUnique(
+ inset->params().getContents(),
+ params.getContents());
+ }
+ inset->setParams(params);
+ } else {
+ inset = new InsetBibtex(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
+ }
+ updateInset(inset, true);
}
break;
- case LFUN_INSERT_BIBTEX:
- {
- // ale970405+lasgoutt970425
- // The argument can be up to two tokens separated
- // by a space. The first one is the bibstyle.
- string const db = token(ev.argument, ' ', 0);
- string bibstyle = token(ev.argument, ' ', 1);
- if (bibstyle.empty())
- bibstyle = "plain";
-
- InsetCommandParams p("BibTeX", db, bibstyle);
- InsetBibtex * inset = new InsetBibtex(p);
-
- if (insertInset(inset)) {
- if (ev.argument.empty())
- inset->edit(bv_);
- } else
- delete inset;
+ case LFUN_CITATION_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base =
+ owner_->getDialogs().getOpenInset("citation");
+ InsetCitation * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetCitation *>(base);
+ if (!inset)
+ break;
+
+ inset->setParams(params);
+ } else {
+ inset = new InsetCitation(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ } else {
+ inset->setLoadingBuffer(bv_->buffer(), false);
+ }
+ }
+ updateInset(inset, true);
}
break;
- // BibTeX data bases
- case LFUN_BIBDB_ADD:
- {
- InsetBibtex * inset =
- static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
- if (inset) {
- inset->addDatabase(ev.argument);
+ case LFUN_ERT_APPLY: {
+ InsetBase * base = owner_->getDialogs().getOpenInset("ert");
+ InsetERT * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetERT *>(base);
+ if (!inset)
+ break;
+ } else {
+ inset = new InsetERT(bv_->buffer()->params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
}
+
+ InsetERT::ERTStatus status;
+ InsetERTMailer::string2params(ev.argument, status);
+
+ inset->status(bv_, status);
+ updateInset(inset, true);
}
break;
- case LFUN_BIBDB_DEL:
- {
- InsetBibtex * inset =
- static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
- if (inset)
- inset->delDatabase(ev.argument);
+ case LFUN_INDEX_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base = owner_->getDialogs().getOpenInset("index");
+ InsetIndex * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetIndex *>(base);
+ if (!inset)
+ break;
+
+ inset->setParams(params);
+ } else {
+ InsetIndex * inset = new InsetIndex(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
+ }
+ updateInset(inset, true);
}
break;
- case LFUN_BIBTEX_STYLE:
- {
- InsetBibtex * inset =
- static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
- if (inset)
- inset->setOptions(ev.argument);
+ case LFUN_REF_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base = owner_->getDialogs().getOpenInset("ref");
+ InsetRef * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetRef *>(base);
+ if (!inset)
+ break;
+
+ inset->setParams(params);
+ } else {
+ InsetRef * inset = new InsetRef(params, *buffer_);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
+ }
+ updateInset(inset, true);
+ }
+ break;
+
+ case LFUN_TOC_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base = owner_->getDialogs().getOpenInset("toc");
+ InsetTOC * inset = 0;
+ if (base) {
+ InsetTOC * inset = dynamic_cast<InsetTOC *>(base);
+ if (!inset)
+ break;
+
+ inset->setParams(params);
+ } else {
+ InsetTOC * inset = new InsetTOC(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
+ }
+ updateInset(inset, true);
+ }
+ break;
+
+ case LFUN_URL_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(ev.argument, params);
+
+ InsetBase * base = owner_->getDialogs().getOpenInset("url");
+ InsetUrl * inset = 0;
+ if (base) {
+ inset = dynamic_cast<InsetUrl *>(base);
+ if (!inset)
+ break;
+
+ inset->setParams(params);
+ } else {
+ InsetUrl * inset = new InsetUrl(params);
+ if (!insertInset(inset)) {
+ delete inset;
+ break;
+ }
+ }
+ updateInset(inset, true);
}
break;
* toc.C: make TocItem store an id not a Paragraph *
(bug #913)
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * commandtags.h: Retire LFUN_CITATION_INSERT, LFUN_CITATION_CREATE,
+ LFUN_INSERT_BIBTEX, LFUN_BIBTEX_STYLE, LFUN_BIBDB_ADD, LFUN_BIBDB_DEL.
+ Bring to life LFUN_DIALOG_SHOW_NEW_INSET, LFUN_DIALOG_SHOW_NEXT_INSET,
+ LFUN_DIALOG_UPDATE, LFUN_DIALOG_HIDE, LFUN_DIALOG_DISCONNECT_INSET,
+ LFUN_BIBITEM_APPLY, LFUN_BIBTEX_APPLY, LFUN_CITATION_APPLY,
+ LFUN_INDEX_APPLY, LFUN_REF_APPLY, LFUN_TOC_APPLY, LFUN_URL_APPLY,
+
+ * BufferView_pimpl.C (dispatch):
+ * LyXAction.C (init):
+ * factory.C (createInset):
+ * lyxfunc.C (getStatus, dispatch):
+ * text3.C (dispatch): retire old LFUNs and bring new ones to life.
+
2003-02-21 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (MenuInsertLyXFile):
NoBuffer|ReadOnly },
{ LFUN_LEFTSEL, "backward-select",
N_("Select previous char"), ReadOnly },
- { LFUN_BIBDB_ADD, "bibtex-database-add", "", Noop },
- { LFUN_BIBDB_DEL, "bibtex-database-del", "", Noop },
- { LFUN_INSERT_BIBTEX, "bibtex-insert", N_("Insert BibTeX"),
- Noop },
- { LFUN_BIBTEX_STYLE, "bibtex-style", "", Noop },
{ LFUN_BOOKMARK_GOTO, "bookmark-goto", "", ReadOnly },
{ LFUN_BOOKMARK_SAVE, "bookmark-save", "", ReadOnly },
{ LFUN_BREAKLINE, "break-line", "", Noop },
ReadOnly },
{ LFUN_RIGHT, "char-forward", N_("Go one char forward"),
ReadOnly },
- { LFUN_CITATION_CREATE, "citation-insert",
- N_("Insert citation"), Noop },
- { LFUN_CITATION_INSERT, "", "internal only", Noop },
{ LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer },
{ LFUN_PREFIX, "command-prefix",
N_("Execute command"), NoBuffer },
Noop },
{ LFUN_INSET_OPTARG, "optional-insert", N_("Insert Optional Argument"),
Noop },
- { LFUN_INSERT_BIBITEM, "bibitem-insert", N_("Insert Bibliography Key"),
- Noop },
+ { LFUN_INSERT_BIBITEM, "bibitem-insert",
+ N_("Insert Bibliography Key"), Noop },
{ LFUN_LANGUAGE, "language", N_("Change language"), Noop },
{ LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
ReadOnly },
{ LFUN_ACCEPT_CHANGE, "accept-change", N_("Accept selected change"), Noop },
{ LFUN_REJECT_CHANGE, "reject-change", N_("Reject selected change"), Noop },
{ LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", N_("Accept all changes"), Noop },
- { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", N_("Reject all changes"), Noop },
+ { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", N_("Reject all changes"), Noop },
+
+ { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset",
+ N_("Show the inset's dialog"), Noop },
+ { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-next-inset",
+ N_("Show the inset's dialog"), Noop },
+ { LFUN_DIALOG_UPDATE, "dialog-update",
+ N_("Update the dialog"), Noop },
+ { LFUN_DIALOG_HIDE, "dialog-hide",
+ N_("Hide the dialog"), Noop },
+ { LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset",
+ N_("Disconnect the dialog from the current inset"), Noop },
+ { LFUN_BIBITEM_APPLY, "bibitem-apply", "", Noop },
+ { LFUN_BIBTEX_APPLY, "bibtex-apply", "", Noop },
+ { LFUN_CITATION_APPLY, "citation-apply", "", Noop },
+ { LFUN_ERT_APPLY, "ert-apply", "", Noop },
+ { LFUN_INDEX_APPLY, "index-apply", "", Noop },
+ { LFUN_REF_APPLY, "ref-apply", "", Noop },
+ { LFUN_TOC_APPLY, "toc-apply", "", Noop },
+ { LFUN_URL_APPLY, "url-apply", "", Noop },
{ LFUN_NOACTION, "", "", Noop }
};
-// -*- C++ -*-
+// -*- C++ --*
/* ======================================================================= *\
Docu : To add a new function:
- add a new enum constant immediately before LFUN_LASTACTION
LFUN_MENUNEWTMPLT, // Asger 1997-02-02
LFUN_MENURELOAD, // Asger 1997-02-02
LFUN_RECONFIGURE, // 170 // Asger 1997-02-14
- LFUN_CITATION_INSERT, // AAS 97-02-23
- LFUN_INSERT_BIBTEX, // AAS 97-02-23
LFUN_INDEX_PRINT, // Lgb 97-02-27
LFUN_APROPOS, // Asger 1997-02-27
LFUN_LATEX_LOG, // Lgb 97-04-05
LFUN_TOC_INSERT, // Lgb 97-05-27
LFUN_FLOAT_LIST, // Lgb 20010503
LFUN_READ_ONLY_TOGGLE, // Lgb 97-05-27
- LFUN_BIBDB_ADD, // Ale 970530
- LFUN_BIBDB_DEL, // Ale 970530
- LFUN_BIBTEX_STYLE, // 190 // Ale 970530
LFUN_GETTIP, // Ale 970603
LFUN_VC_REGISTER, // Lgb 97-07-01
LFUN_VC_CHECKIN, // Lgb 97-07-01
LFUN_INSET_LIST, // Lgb 20000627
LFUN_INSET_THEOREM, // Lgb 20000630
#endif
- LFUN_CITATION_CREATE, // 240 // Angus 20000705
LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this coming from?
LFUN_INSERT_URL, // Angus 20000726
LFUN_REJECT_CHANGE, // Levon 20021016
LFUN_ACCEPT_ALL_CHANGES, // Levon 20021016
LFUN_REJECT_ALL_CHANGES, // Levon 20021016
- LFUN_INSERT_BIBITEM, // André 14 Feb 2003
+ LFUN_INSERT_BIBITEM, // André 14 Feb 2003
+ LFUN_DIALOG_SHOW_NEW_INSET,
+ LFUN_DIALOG_SHOW_NEXT_INSET,
+ LFUN_DIALOG_UPDATE,
+ LFUN_DIALOG_HIDE,
+ LFUN_DIALOG_DISCONNECT_INSET,
+ LFUN_BIBITEM_APPLY,
+ LFUN_BIBTEX_APPLY,
+ LFUN_CITATION_APPLY,
+ LFUN_ERT_APPLY,
+ LFUN_INDEX_APPLY,
+ LFUN_REF_APPLY,
+ LFUN_TOC_APPLY,
+ LFUN_URL_APPLY,
LFUN_LASTACTION /* this marks the end of the table */
};
return 0;
case LFUN_INDEX_INSERT: {
- string const entry = cmd.argument.empty() ?
- "index" : cmd.argument;
- InsetCommandParams icp;
- icp.setFromString(entry);
-
- if (icp.getContents().empty())
- icp.setContents(bv->getLyXText()->getStringToIndex(bv));
- if (!icp.getContents().empty())
- return new InsetIndex(icp);
-
- bv->owner()->getDialogs().createIndex();
+ // Try and generate a valid index entry.
+ InsetCommandParams icp("index");
+ string const contents = cmd.argument.empty() ?
+ bv->getLyXText()->getStringToIndex(bv) :
+ cmd.argument;
+ icp.setContents(contents);
+
+ string data = InsetCommandMailer::params2string(icp);
+ LyXView * lv = bv->owner();
+
+ if (icp.getContents().empty()) {
+ lv->getDialogs().show("index", data, 0);
+ } else {
+ FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
+ lv->dispatch(fr);
+ }
return 0;
}
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.[Ch]: simplify the dialog interface by using a few
+ methods to do generic things like 'show' a dialog. Individual
+ dialogs are invoked through a string 'name'.
+ Use methods 'hideAll' etc to replace signals of the same name: more
+ transparent code.
+
+ * guiapi.[Ch]: provide a C-interface to the new Dialogs::show
+ method. Retire the old functions that called dead Dialogs methods.
+
2003-02-21 Angus Leeming <leeming@lyx.org>
* Timeout.[Ch]: define a Timeout::Impl abstract base class from
#include <config.h>
-
#include "Dialogs.h"
+#include "controllers/Dialog.h"
+#include "controllers/ButtonControllerBase.h"
+#include <boost/bind.hpp>
+
// Note that static boost signals break some compilers, so this wrapper
// initialises the signal dynamically when it is first invoked.
static BugfixSignal<boost::signal0<void> > thesignal;
return thesignal();
}
+
+
+Dialogs::Dialogs(LyXView & lyxview)
+ : lyxview_(lyxview)
+{
+ // Connect signals
+ redrawGUI().connect(boost::bind(&Dialogs::redraw, this));
+
+ // All this is slated to go
+ init_pimpl();
+ // reduce the number of connections needed in
+ // dialogs by a simple connection here.
+ hideAllSignal.connect(hideBufferDependentSignal);
+}
+
+
+Dialog * Dialogs::find(string const & name)
+{
+ if (!isValidName(name))
+ return 0;
+
+ std::map<string, DialogPtr>::iterator it =
+ dialogs_.find(name);
+
+ if (it == dialogs_.end()) {
+ dialogs_[name] = DialogPtr(build(name));
+ return dialogs_[name].get();
+ }
+
+ return it->second.get();
+}
+
+
+void Dialogs::show(string const & name, string const & data, InsetBase * inset)
+{
+ Dialog * dialog = find(name);
+ if (!dialog)
+ return;
+
+ dialog->show(data);
+ open_insets_[name] = inset;
+}
+
+
+void Dialogs::update(string const & name, string const & data)
+{
+ Dialog * dialog = find(name);
+ if (!dialog)
+ return;
+
+ if (dialog->isVisible())
+ dialog->update(data);
+}
+
+
+void Dialogs::hide(string const & name)
+{
+ Dialog * dialog = find(name);
+ if (!dialog)
+ return;
+
+ if (dialog->isVisible())
+ dialog->hide();
+ open_insets_[name] = 0;
+}
+
+
+void Dialogs::disconnect(string const & name)
+{
+ if (!isValidName(name))
+ return;
+
+ open_insets_[name] = 0;
+}
+
+
+InsetBase * Dialogs::getOpenInset(string const & name) const
+{
+ if (!isValidName(name))
+ return 0;
+
+ std::map<string, InsetBase *>::const_iterator it =
+ open_insets_.find(name);
+ return it == open_insets_.end() ? 0 : it->second;
+}
+
+
+void Dialogs::hideAll() const
+{
+ std::map<string, DialogPtr>::const_iterator it = dialogs_.begin();
+ std::map<string, DialogPtr>::const_iterator end = dialogs_.end();
+
+ for(; it != end; ++it) {
+ it->second->hide();
+ }
+ hideAllSignal();
+}
+
+
+void Dialogs::hideBufferDependent() const
+{
+ std::map<string, DialogPtr>::const_iterator it = dialogs_.begin();
+ std::map<string, DialogPtr>::const_iterator end = dialogs_.end();
+
+ for(; it != end; ++it) {
+ Dialog * dialog = it->second.get();
+ if (dialog->controller().isBufferDependent())
+ dialog->hide();
+ }
+ hideBufferDependentSignal();
+}
+
+
+void Dialogs::updateBufferDependent(bool switched) const
+{
+ std::map<string, DialogPtr>::const_iterator it = dialogs_.begin();
+ std::map<string, DialogPtr>::const_iterator end = dialogs_.end();
+
+ for(; it != end; ++it) {
+ Dialog * dialog = it->second.get();
+ if (switched && dialog->controller().isBufferDependent()) {
+ dialog->hide();
+ } else {
+ // A bit clunky, but the dialog will request
+ // that the kernel provides it with the necessary
+ // data.
+ dialog->RestoreButton();
+ }
+ }
+ updateBufferDependentSignal(switched);
+}
+
+
+void Dialogs::redraw() const
+{
+ std::map<string, DialogPtr>::const_iterator it = dialogs_.begin();
+ std::map<string, DialogPtr>::const_iterator end = dialogs_.end();
+
+ for(; it != end; ++it) {
+ it->second->redraw();
+ }
+}
#include <boost/signals/signal0.hpp>
#include <boost/signals/signal1.hpp>
+class Dialog;
+class InsetBase;
class LyXView;
+
class InsetCommand;
class InsetError;
-class InsetERT;
class InsetExternal;
class InsetFloat;
class InsetWrap;
/// Are the tooltips on or off?
static bool tooltipsEnabled();
- /**@name Global Hide and Update Signals */
+ /// Signals slated to go
//@{
- /// Hide all visible dialogs
- boost::signal0<void> hideAll;
+ boost::signal0<void> hideAllSignal;
+ boost::signal0<void> hideBufferDependentSignal;
+ boost::signal1<void, bool> updateBufferDependentSignal;
+ //@}
+ /// Hide all visible dialogs
+ void hideAll() const;
/// Hide any dialogs that require a buffer for them to operate
- boost::signal0<void> hideBufferDependent;
-
+ void hideBufferDependent() const;
/** Update visible, buffer-dependent dialogs
If the bool is true then a buffer change has occurred
else its still the same buffer.
*/
- boost::signal1<void, bool> updateBufferDependent;
- //@}
+ void updateBufferDependent(bool) const ;
/**@name Dialog Access Signals.
Put into some sort of alphabetical order */
//@{
///
void showAboutlyx();
- /// show the key and label of a bibliography entry
- void showBibitem(InsetCommand * ic);
- /// show the bibtex dialog
- void showBibtex(InsetCommand * ic);
///
void showCharacter();
/// connected to the character dialog also
void setUserFreeFont();
///
- void showCitation(InsetCommand *);
- ///
- void createCitation(string const &);
- ///
void showDocument();
- ///
- void showError(InsetError *);
- ///
- void showERT(InsetERT *);
- ///
- void updateERT(InsetERT *);
/// show the external inset dialog
void showExternal(InsetExternal *);
/// show the contents of a file.
void showGraphics(InsetGraphics *);
/// show the details of a LyX file include inset
void showInclude(InsetInclude *);
- ///
- void showIndex(InsetCommand *);
- ///
- void createIndex();
/// show the LaTeX log or build file
void showLogFile();
/// display the top-level maths panel
///
void showPrint();
///
- void showRef(InsetCommand *);
- ///
- void createRef(string const &);
- ///
void showSearch();
///
void showSendto();
void showTexinfo();
/// show the thesaurus dialog
void showThesaurus(string const &);
- ///
- void showTOC(InsetCommand *);
- ///
- void createTOC(string const &);
- ///
- void showUrl(InsetCommand *);
- ///
- void createUrl(string const &);
/// show the version control log
void showVCLogFile();
//@}
+ /** name == "bibtex", "citation" etc
+ data is generated by the Inset::write method, to be read by the
+ Inset::read method in the frontends.
+ inset is stored. On a subsequent Apply from the frontends, the
+ stored inset will be modified. If no inset is stored, then a
+ new one will be created at the current cursor position.
+ */
+ void show(string const & name, string const & data, InsetBase * inset);
+ /** name == "citation", "bibtex" etc.
+ Update the contents of the dialog.
+ */
+ void update(string const & name, string const & data);
+ ///
+ void Dialogs::hide(string const & name);
+ ///
+ void disconnect(string const & name);
+ ///
+ InsetBase * getOpenInset(string const & name) const;
private:
- /// Use the Pimpl idiom to hide the internals.
+ ///
+ void redraw() const;
+ ///
+ bool isValidName(string const & name) const;
+ ///
+ Dialog * find(string const & name);
+ ///
+ Dialog * build(string const & name);
+
+ ///
+ LyXView & lyxview_;
+ ///
+ std::map<string, InsetBase *> open_insets_;
+
+ ///
+ typedef boost::shared_ptr<Dialog> DialogPtr;
+ ///
+ std::map<string, DialogPtr> dialogs_;
+
+ /// the stuff below is slated to go...
+ void init_pimpl();
+ ///
class Impl;
- /// The pointer never changes although *pimpl_'s contents may.
- boost::scoped_ptr<Impl> const pimpl_;
+ ///
+ Impl * pimpl_;
};
#endif
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * Dialog.[Ch]:
+ * Kernel.[Ch]: a new, transparent MCV split of the dialogs code.
+
+ * ControlBibitem.[Ch]:
+ * ControlBibtex.[Ch]:
+ * ControlCitation.[Ch]:
+ * ControlCommand.[Ch]:
+ * ControlError.[Ch]:
+ * ControlIndex.[Ch]:
+ * ControlRef.[Ch]:
+ * ControlToc.[Ch]:
+ * ControlUrl.[Ch]: New MCV design leads to cleaner code for the
+ individual controllers too.
+ Move 'apply' code into the LyX kernel.
+
+ * ControlConnections.C: temporary renaming of Dialogs::signals.
+
+ * Makefile.am: add new files.
+
2003-02-21 Angus Leeming <leeming@lyx.org>
* ControlBibtex.C (Browse):
#include <config.h>
-
#include "ControlBibitem.h"
-#include "BufferView.h"
-ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d)
+ControlBibitem::ControlBibitem(Dialog & d)
+ : ControlCommand(d, LFUN_BIBITEM_APPLY)
{}
-
-
-void ControlBibitem::applyParamsToInset()
-{
- // FIXME:
- // confirm, is this only necessary for FormBibTeX ???
- if (params().getContents() != inset()->params().getContents())
- bufferview()->ChangeCitationsIfUnique(inset()->params().getContents(),
- params().getContents());
-
- inset()->setParams(params());
- bufferview()->updateInset(inset(), true);
-
- // We need to do a redraw because the maximum
- // InsetBibKey width could have changed
-#warning please check you mean repaint() not update(),
-#warning and whether the repaint() is needed at all
- bufferview()->repaint();
- bufferview()->fitCursor();
-}
class ControlBibitem : public ControlCommand {
public:
///
- ControlBibitem(LyXView &, Dialogs &);
-private:
- /// Dispatch the changed parameters to the kernel.
- virtual void applyParamsToInset();
- /// not needed.
- virtual void applyParamsNoInset() {}
+ ControlBibitem(Dialog &);
};
#endif // CONTROLBIBITEM_H
#include <config.h>
-
#include "ControlBibtex.h"
+#include "Kernel.h"
+
#include "buffer.h"
-#include "BufferView.h"
#include "lyxrc.h"
#include "helper_funcs.h"
#include "tex_helpers.h"
#include "gettext.h"
-#include "support/lstrings.h"
-
using std::pair;
-ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d)
-{}
-
-
-
-void ControlBibtex::applyParamsToInset()
-{
- if (params().getContents() != inset()->params().getContents())
- bufferview()->ChangeCitationsIfUnique(inset()->params().getContents(),
- params().getContents());
-
- inset()->setParams(params());
- bufferview()->updateInset(inset(), true);
-
- // We need to do a redraw because the maximum
- // InsetBibKey width could have changed
-#warning are you sure you need this repaint() ?
- bufferview()->repaint();
- bufferview()->fitCursor();
-}
-
-
-void ControlBibtex::applyParamsNoInset()
+ControlBibtex::ControlBibtex(Dialog & d)
+ : ControlCommand(d, LFUN_BIBTEX_APPLY)
{}
{
pair<string, string> dir1(_("Documents|#o#O"),
string(lyxrc.document_path));
- return browseRelFile(in_name, buffer()->filePath(),
+ return browseRelFile(in_name, kernel().buffer()->filePath(),
title, pattern, false, dir1);
}
#include "ControlCommand.h"
+
/** A controller for Bibtex dialogs.
*/
class ControlBibtex : public ControlCommand {
public:
///
- ControlBibtex(LyXView &, Dialogs &);
+ ControlBibtex(Dialog &);
+
/// Browse for a file
string const Browse(string const &, string const &, string const &);
/// get the list of bst files
/// build filelists of all availabe bib/bst/cls/sty-files. done through
/// kpsewhich and an external script, saved in *Files.lst
void rescanBibStyles() const;
-private:
- /// Dispatch the changed parameters to the kernel.
- virtual void applyParamsToInset();
- ///
- virtual void applyParamsNoInset();
};
+
#endif // CONTROLBIBTEX_H
#include <config.h>
-
#include "ControlCitation.h"
+#include "Kernel.h"
+
#include "buffer.h"
using std::vector;
vector<biblio::CiteStyle> ControlCitation::citeStyles_;
-ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_CITATION_INSERT)
+ControlCitation::ControlCitation(Dialog & d)
+ : ControlCommand(d, LFUN_CITATION_APPLY)
{}
-void ControlCitation::clearDaughterParams()
+void ControlCitation::initialiseParams(string const & data)
{
- bibkeysInfo_.clear();
-}
-
+ ControlCommand::initialiseParams(data);
-void ControlCitation::setDaughterParams()
-{
vector<pair<string,string> > blist;
- buffer()->fillWithBibKeys(blist);
+ kernel().buffer()->fillWithBibKeys(blist);
typedef std::map<string, string>::value_type InfoMapValue;
}
+
+void ControlCitation::clearParams()
+{
+ ControlCommand::clearParams();
+ bibkeysInfo_.clear();
+}
+
+
biblio::InfoMap const & ControlCitation::bibkeysInfo() const
{
return bibkeysInfo_;
bool ControlCitation::usingNatbib() const
{
- return buffer()->params.use_natbib;
+ return kernel().buffer()->params.use_natbib;
}
vector<biblio::CiteStyle> const cs =
biblio::getCiteStyles(usingNatbib());
- if (buffer()->params.use_numerical_citations)
+ if (kernel().buffer()->params.use_numerical_citations)
styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs);
else
styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
class ControlCitation : public ControlCommand {
public:
///
- ControlCitation(LyXView &, Dialogs &);
+ ControlCitation(Dialog &);
+
+ ///
+ virtual void initialiseParams(string const & data);
+ /// clean-up on hide.
+ virtual void clearParams();
+
+ /** Disconnect from the inset when the Apply button is pressed.
+ * Allows easy insertion of multiple citations.
+ */
+ virtual bool disconnectOnApply() const { return true; }
/// Returns a reference to the map of stored keys
biblio::InfoMap const & bibkeysInfo() const;
return citeStyles_;
}
private:
- /// create the InfoMap of keys and data
- virtual void setDaughterParams();
- ///
- virtual void clearDaughterParams();
-
- /** disconnect from the inset when the Apply button is pressed.
- Allows easy insertion of multiple citations. */
- virtual bool disconnectOnApply() { return true; }
-
/// The info associated with each key
biblio::InfoMap bibkeysInfo_;
#include <config.h>
-
#include "ControlCommand.h"
+#include "Kernel.h"
-#include "BufferView.h"
#include "funcrequest.h"
-#include "lyxfunc.h"
+#include "insets/insetcommand.h"
-ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
- : ControlInset<InsetCommand, InsetCommandParams>(lv, d),
+ControlCommand::ControlCommand(Dialog & dialog, kb_action ac)
+ : Dialog::Controller(dialog),
action_(ac)
{}
-InsetCommandParams const ControlCommand::getParams(string const & arg)
-{
- InsetCommandParams params;
- params.setFromString(arg);
- return params;
-}
-
-
-InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset)
+void ControlCommand::initialiseParams(string const & data)
{
- return inset.params();
+ InsetCommandMailer::string2params(data, params_);
}
-void ControlCommand::applyParamsToInset()
+void ControlCommand::clearParams()
{
- inset()->setParams(params());
- bufferview()->updateInset(inset(), true);
+ params_.setCmdName(string());
+ params_.setOptions(string());
+ params_.setContents(string());
}
-void ControlCommand::applyParamsNoInset()
+void ControlCommand::dispatchParams()
{
if (action_ == LFUN_NOACTION)
return;
- lyxfunc().dispatch(FuncRequest(action_, params().getAsString()));
+
+ FuncRequest fr(action_, InsetCommandMailer::params2string(params_));
+ kernel().dispatch(fr);
}
*
* ControlCommand is a controller class for dialogs that create or modify
* an inset derived from InsetCommand.
- *
- * The class is likely to be changed as other Inset controllers are created
- * and it becomes clear just what functionality can be moved back into
- * ControlInset.
- *
*/
#ifndef CONTROLCOMMAND_H
#define CONTROLCOMMAND_H
-#include "ControlInset.h"
-#include "insets/insetcommand.h"
+#include "Dialog.h"
+#include "insets/insetcommandparams.h"
#include "commandtags.h" // kb_action
-/** The Inset dialog controller. Connects/disconnects signals, launches
- GUI-dependent View and returns the output from this View to the kernel.
- */
-class ControlCommand
- : public ControlInset<InsetCommand, InsetCommandParams>
-{
+
+class ControlCommand : public Dialog::Controller {
public:
///
- ControlCommand(LyXView &, Dialogs &, kb_action=LFUN_NOACTION);
-private:
- /// Dispatch the changed parameters to the kernel.
- virtual void applyParamsToInset();
+ ControlCommand(Dialog &, kb_action=LFUN_NOACTION);
///
- virtual void applyParamsNoInset();
- /// get the parameters from the string passed to createInset.
- virtual InsetCommandParams const getParams(string const &);
- /// get the parameters from the inset passed to showInset.
- virtual InsetCommandParams const getParams(InsetCommand const &);
+ InsetCommandParams & params() { return params_; }
+ ///
+ InsetCommandParams const & params() const { return params_; }
+ ///
+ virtual void initialiseParams(string const & data);
+ /// clean-up on hide.
+ virtual void clearParams();
+ /// clean-up on hide.
+ virtual void dispatchParams();
+ ///
+ virtual bool isBufferDependent() const { return true; }
- /// Controls what is done in LyXFunc::Dispatch()
+private:
+ ///
+ InsetCommandParams params_;
+ /// Flags what action is taken by Kernel::dispatch()
kb_action const action_;
};
void ControlConnectBI::connect()
{
- h_ = d_.hideAll.connect(boost::bind(&ControlConnectBI::hide, this));
+ h_ = d_.hideAllSignal.connect(boost::bind(&ControlConnectBI::hide, this));
ControlConnectBase::connect();
}
void ControlConnectBD::connect()
{
- u_ = d_.updateBufferDependent.
+ u_ = d_.updateBufferDependentSignal.
connect(boost::bind(&ControlConnectBD::updateSlot, this, _1));
- h_ = d_.hideBufferDependent.
+ h_ = d_.hideBufferDependentSignal.
connect(boost::bind(&ControlConnectBD::hide, this));
ControlConnectBase::connect();
}
#include <config.h>
-
#include "ControlERT.h"
-
-// sorry this is just a temporary hack we should include vspace.h! (Jug)
-extern const char * stringFromUnit(int);
+#include "funcrequest.h"
-ControlERT::ControlERT(LyXView & lv, Dialogs & d)
- : ControlInset<InsetERT, ERTParams>(lv, d)
+ControlERT::ControlERT(Dialog & parent)
+ : Dialog::Controller(parent), status_(InsetERT::Collapsed)
{}
-void ControlERT::applyParamsToInset()
-{
- inset()->status(bufferview(), params().status);
-}
-
-
-void ControlERT::applyParamsNoInset()
-{
-}
-
-
-ERTParams const ControlERT::getParams(InsetERT const & inset)
+void ControlERT::initialiseParams(string const & data)
{
- return ERTParams(inset);
+ InsetERTMailer::string2params(data, status_);
}
-ERTParams::ERTParams()
- : status(InsetERT::Collapsed)
-{}
-
-
-ERTParams::ERTParams(InsetERT const & inset)
- : status(inset.status())
-{}
-
-
-bool operator==(ERTParams const & p1, ERTParams const & p2)
+void ControlERT::clearParams()
{
- return (p1.status == p2.status);
+ status_ = InsetERT::Collapsed;
}
-bool operator!=(ERTParams const & p1, ERTParams const & p2)
+void ControlERT::dispatchParams()
{
- return !(p1 == p2);
+ FuncRequest fr(LFUN_ERT_APPLY, InsetERTMailer::params2string(status_));
+ kernel().dispatch(fr);
}
#ifndef CONTROLERT_H
#define CONTROLERT_H
-#include <vector>
+#include "Dialog.h"
+#include "insets/insetert.h" // InsetERT::ERTStatus
-#include "ControlInset.h"
-#include "insets/insetert.h" // InsetERT::Status
-/** This should be moved back into insetert.h and InsetERT should
- contain an instance of it. */
-
-struct ERTParams {
+class ControlERT : public Dialog::Controller {
+public:
///
- ERTParams();
+ ControlERT(Dialog &);
///
- ERTParams(InsetERT const &);
+ InsetERT::ERTStatus status() const { return status_; }
///
- InsetERT::ERTStatus status;
-};
-
-
-///
-bool operator==(ERTParams const &, ERTParams const &);
-///
-bool operator!=(ERTParams const &, ERTParams const &);
-
-
-/** A controller for ERT dialogs.
- */
-class ControlERT : public ControlInset<InsetERT, ERTParams> {
-public:
+ void setStatus(InsetERT::ERTStatus status) { status_ = status; }
+ ///
+ virtual void initialiseParams(string const & data);
+ /// clean-up on hide.
+ virtual void clearParams();
+ /// clean-up on hide.
+ virtual void dispatchParams();
///
- ControlERT(LyXView &, Dialogs &);
+ virtual bool isBufferDependent() const { return true; }
private:
- /// Dispatch the changed parameters to the kernel.
- virtual void applyParamsToInset();
///
- virtual void applyParamsNoInset();
- /// get the parameters from the string passed to createInset.
- virtual ERTParams const getParams(string const &)
- { return ERTParams(); }
- /// get the parameters from the inset passed to showInset.
- virtual ERTParams const getParams(InsetERT const &);
+ InsetERT::ERTStatus status_;
};
#endif
#include <config.h>
-
#include "ControlError.h"
-#include "insets/inseterror.h"
-ControlError::ControlError(LyXView & lv, Dialogs & d)
- : ControlInset<InsetError, string>(lv, d)
+ControlError::ControlError(Dialog & parent)
+ : Dialog::Controller(parent)
{}
-string const ControlError::getParams(InsetError const & inset)
+void ControlError::initialiseParams(string const & data)
+{
+ params_ = data;
+}
+
+
+void ControlError::clearParams()
{
- return inset.getContents();
+ params_.clear();
}
+
#define CONTROLERROR_H
-#include "ControlInset.h"
-#include "insets/inseterror.h" // needed for proper instantiation of GUI<>.
+#include "Dialog.h"
-class InsetError;
-/** A controller for LaTeX Error dialogs.
- */
-class ControlError : public ControlInset<InsetError, string> {
+class ControlError : public Dialog::Controller {
public:
///
- ControlError(LyXView &, Dialogs &);
+ ControlError(Dialog &);
+ ///
+ virtual void initialiseParams(string const &);
+ ///
+ virtual void clearParams();
+ ///
+ virtual void dispatchParams() {}
+ ///
+ virtual bool isBufferDependent() const { return true; }
+ ///
+ string & params() { return params_; }
+ ///
+ string const & params() const { return params_; }
+ ///
private:
- /// not needed.
- virtual void applyParamsToInset() {}
- ///
- virtual void applyParamsNoInset() {}
- /// get the parameters from the string passed to createInset.
- virtual string const getParams(string const &) { return string(); }
- /// get the parameters from the inset passed to showInset.
- virtual string const getParams(InsetError const &);
+ string params_;
};
#endif // CONTROLERROR_H
#include "ControlIndex.h"
-ControlIndex::ControlIndex(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_INDEX_INSERT)
+ControlIndex::ControlIndex(Dialog & d)
+ : ControlCommand(d, LFUN_INDEX_APPLY)
{}
class ControlIndex : public ControlCommand {
public:
///
- ControlIndex(LyXView &, Dialogs &);
+ ControlIndex(Dialog &);
};
#endif // CONTROLINDEX_H
extern BufferList bufferlist;
-ControlRef::ControlRef(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_REF_INSERT)
+ControlRef::ControlRef(Dialog & d)
+ : ControlCommand(d, LFUN_REF_APPLY)
{}
{
Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
if (!buf)
- buf = buffer();
+ buf = kernel().buffer();
return buf->getLabelList();
}
void ControlRef::gotoRef(string const & ref)
{
- lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
- lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
+ kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
+ kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
}
void ControlRef::gotoBookmark()
{
- lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
+ kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
}
int ControlRef::getBufferNum() const
{
vector<string> buffers = bufferlist.getFileNames();
- string const name = buffer()->fileName();
+ string const name = kernel().buffer()->fileName();
vector<string>::const_iterator cit =
find(buffers.begin(), buffers.end(), name);
if (cit == buffers.end())
#include "ControlCommand.h"
+#include <vector>
+
/** A controller for the Ref Dialog.
*/
class ControlRef : public ControlCommand {
public:
///
- ControlRef(LyXView &, Dialogs &);
+ ControlRef(Dialog &);
///
std::vector<string> const getLabelList(string const &) const;
///
private:
/** disconnect from the inset when the Apply button is pressed.
Allows easy insertion of multiple references. */
- virtual bool disconnectOnApply() { return true; }
+ virtual bool disconnectOnApply() const { return true; }
};
#endif // CONTROLREF_H
#include <config.h>
-
#include "ControlToc.h"
-#include "toc.h"
-
#include "support/lstrings.h" // tostr
using std::vector;
class Buffer;
-ControlToc::ControlToc(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_TOC_INSERT)
+ControlToc::ControlToc(Dialog & d)
+ : ControlCommand(d, LFUN_TOC_APPLY)
{}
-void ControlToc::goTo(toc::TocItem const & item) const
+void ControlToc::goTo(toc::TocItem const & item)
{
- item.goTo(lv_);
+ item.goTo(kernel().lyxview());
}
vector<string> const ControlToc::getTypes() const
{
- return toc::getTypes(buffer());
+ return toc::getTypes(kernel().buffer());
}
toc::Toc empty_list;
// This shouldn't be possible...
- if (!bufferIsAvailable()) {
+ if (!kernel().isBufferAvailable()) {
return empty_list;
}
- toc::TocList tmp = toc::getTocList(buffer());
+ toc::TocList tmp = toc::getTocList(kernel().buffer());
toc::TocList::iterator it = tmp.find(type);
if (it == tmp.end()) {
return empty_list;
#define CONTROLTOC_H
-#include <vector>
#include "ControlCommand.h"
#include "toc.h"
+#include <vector>
/** A controller for TOC dialogs.
*/
class ControlToc : public ControlCommand {
public:
///
- ControlToc(LyXView &, Dialogs &);
+ ControlToc(Dialog &);
/// Goto this paragraph id
- void goTo(toc::TocItem const &) const;
+ void goTo(toc::TocItem const &);
/// Return the list of types available
std::vector<string> const getTypes() const;
#include "ControlUrl.h"
-ControlUrl::ControlUrl(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d, LFUN_INSERT_URL)
+ControlUrl::ControlUrl(Dialog & d)
+ : ControlCommand(d, LFUN_URL_APPLY)
{}
{
public:
///
- ControlUrl(LyXView &, Dialogs &);
+ ControlUrl(Dialog &);
};
#endif // CONTROLURL_H
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file Dialog.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 "Dialog.h"
+
+#include "ButtonControllerBase.h"
+#include "support/LAssert.h"
+
+
+Dialog::Dialog(LyXView & lv, string const & name)
+ : is_closing_(false), kernel_(lv), name_(name)
+{}
+
+
+void Dialog::ApplyButton()
+{
+ apply();
+ bc().apply();
+}
+
+
+void Dialog::OKButton()
+{
+ is_closing_ = true;
+ apply();
+ is_closing_ = false;
+ hide();
+ bc().ok();
+}
+
+
+void Dialog::CancelButton()
+{
+ hide();
+ bc().cancel();
+}
+
+
+void Dialog::RestoreButton()
+{
+ // Tell the kernel that a request to refresh the dialog's contents
+ // has been received. It's up to the kernel to supply the necessary
+ // info by calling Dialog::update().
+ kernel().updateDialog(name_);
+ bc().restore();
+}
+
+
+void Dialog::show(string const & data)
+{
+ if (controller().isBufferDependent() && !kernel().isBufferAvailable())
+ return;
+
+ controller().initialiseParams(data);
+ bc().readOnly(kernel().isBufferReadonly());
+ view().show();
+
+ // The widgets may not be valid, so refresh the button controller
+ bc().refresh();
+}
+
+
+void Dialog::update(string const & data)
+{
+ if (controller().isBufferDependent() && !kernel().isBufferAvailable())
+ return;
+
+ controller().initialiseParams(data);
+
+ bc().readOnly(kernel().isBufferReadonly());
+ view().update();
+
+ // The widgets may not be valid, so refresh the button controller
+ bc().refresh();
+}
+
+
+void Dialog::hide()
+{
+ if (!view().isVisible())
+ return;
+
+ controller().clearParams();
+ view().hide();
+}
+
+
+void Dialog::apply()
+{
+ if (kernel().isBufferReadonly())
+ return;
+
+ view().apply();
+ controller().dispatchParams();
+
+ if (controller().disconnectOnApply() && !is_closing_) {
+ kernel().disconnect(name());
+ controller().initialiseParams(string());
+ view().update();
+ }
+}
+
+
+bool Dialog::isVisible() const
+{
+ return view().isVisible();
+}
+
+
+void Dialog::redraw()
+{
+ view().redraw();
+}
+
+
+ButtonControllerBase & Dialog::bc() const
+{
+ lyx::Assert(bc_ptr_.get());
+ return *bc_ptr_.get();
+}
+
+
+Dialog::Controller & Dialog::controller() const
+{
+ lyx::Assert(controller_ptr_.get());
+ return *controller_ptr_.get();
+}
+
+
+Dialog::View & Dialog::view() const
+{
+ lyx::Assert(view_ptr_.get());
+ return *view_ptr_.get();
+}
+
+
+void Dialog::setButtonController(ButtonControllerBase * bc)
+{
+ lyx::Assert(bc && !bc_ptr_.get());
+ bc_ptr_.reset(bc);
+}
+
+
+void Dialog::setController(Controller * i)
+{
+ lyx::Assert(i && !controller_ptr_.get());
+ controller_ptr_.reset(i);
+}
+
+
+void Dialog::setView(View * v)
+{
+ lyx::Assert(v && !view_ptr_.get());
+ view_ptr_.reset(v);
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file Dialog.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
+ *
+ * The dialogs use a Model-Controller-View split, instantiated here
+ * by class Dialog.
+ */
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+
+#include "Kernel.h"
+#include "LString.h"
+#include <boost/utility.hpp>
+#include <boost/scoped_ptr.hpp>
+
+
+class LyXView;
+class ButtonControllerBase;
+
+
+class Dialog : boost::noncopyable {
+public:
+ /** the Dialog's "name" is the means with which a dialog identifies
+ * itself to the kernel.
+ */
+ Dialog(LyXView &, string const & name);
+
+ ///
+ string const & name() const { return name_; }
+
+ /** These methods are publicly accessible because they are invoked
+ by the View.
+ */
+ //@{
+ ///
+ void ApplyButton();
+ ///
+ void OKButton();
+ ///
+ void CancelButton();
+ ///
+ void RestoreButton();
+ //@}
+
+ /** These methods are publicly accessible because they are invoked
+ * by the Dialogs class.
+ */
+ //@{
+ /** Some dialogs, eg the Tabular or Preferences dialog, can extract
+ the information they require from the kernel. These dialogs will
+ probably be passed an empty string by the calling Dialogs class.
+ The inset dialogs, however, require information specific to
+ an individual inset. This information will be encoded in "data"
+ and must be translated into a set of parameters that can be
+ updated from the dialog.
+ */
+ void show(string const & data = string());
+ ///
+ void update(string const & data = string());
+ ///
+ void hide();
+ ///
+ bool isVisible() const;
+ /// (Eg, the GUI colours have been changed.)
+ void redraw();
+ //@}
+
+ /** When Applying it's useful to know whether the dialog is about
+ * to close or not (no point refreshing the display for example).
+ */
+ bool isClosing() const { return is_closing_; }
+
+ /// The LyX kernel is made available through this.
+ Kernel & kernel() { return kernel_; }
+
+ /** Different dialogs will have different
+ Controllers, Views and ButtonControllers.
+ */
+ //@{
+ ///
+ class Controller;
+ ///
+ class View;
+
+ ///
+ void setController(Controller *);
+ ///
+ void setView(View *);
+ ///
+ void setButtonController(ButtonControllerBase *);
+
+ ///
+ Controller & controller() const;
+ ///
+ ButtonControllerBase & bc() const;
+private:
+ ///
+ View & view() const;
+ //@}
+
+ ///
+ void apply();
+
+ ///
+ bool is_closing_;
+ ///
+ Kernel kernel_;
+ ///
+ string name_;
+ ///
+ boost::scoped_ptr<ButtonControllerBase> bc_ptr_;
+ ///
+ boost::scoped_ptr<Controller> controller_ptr_;
+ ///
+ boost::scoped_ptr<View> view_ptr_;
+};
+
+
+class Dialog::Controller : boost::noncopyable {
+public:
+ ///
+ Controller(Dialog & parent) : parent_(parent) {}
+ ///
+ virtual ~Controller() {}
+ ///
+ virtual void initialiseParams(string const & data) = 0;
+ ///
+ virtual void clearParams() = 0;
+ ///
+ virtual void dispatchParams() = 0;
+ ///
+ virtual bool isBufferDependent() const = 0;
+ ///
+ virtual bool disconnectOnApply() const { return false; }
+ ///
+ Kernel & kernel() { return parent_.kernel(); }
+ ///
+ Kernel const & kernel() const { return parent_.kernel(); }
+
+private:
+ ///
+ Dialog & parent_;
+};
+
+
+class Dialog::View : boost::noncopyable {
+public:
+ ///
+ View(Dialog & parent) : p_(parent) {}
+ ///
+ virtual ~View() {}
+
+ /// Apply changes to LyX data from dialog.
+ virtual void apply() = 0;
+ /// Hide the dialog.
+ virtual void hide() = 0;
+ /// Redraw the dialog (e.g. if the colors have been remapped).
+ virtual void redraw() {}
+ /// Create the dialog if necessary, update it and display it.
+ virtual void show() = 0;
+ /// Update dialog before/whilst showing it.
+ virtual void update() = 0;
+ ///
+ virtual bool isVisible() const = 0;
+
+ /** Defaults to nothing. Can be used by the controller, however, to
+ * indicate to the view that something has changed and that the
+ * dialog therefore needs updating.
+ */
+ virtual void partialUpdate(int) {}
+
+ ///
+ Dialog & dialog() { return p_; }
+ ///
+ Dialog const & dialog() const { return p_; }
+
+ ///
+ Kernel & kernel() { return p_.kernel(); }
+ ///
+ Kernel const & kernel() const { return p_.kernel(); }
+
+ ///
+ Controller & getController() { return p_.controller(); }
+ ///
+ Controller const & getController() const { return p_.controller(); }
+
+protected:
+ ///
+ Dialog & p_;
+};
+
+
+#endif // DIALOG_H
--- /dev/null
+#include "Kernel.h"
+
+#include "buffer.h"
+#include "BufferView.h"
+#include "funcrequest.h"
+#include "lyxfunc.h"
+#include "frontends/Dialogs.h"
+#include "frontends/LyXView.h"
+
+Kernel::Kernel(LyXView & lyxview)
+ : lyxview_(lyxview)
+{}
+
+
+void Kernel::dispatch(FuncRequest const & fr, bool verbose) const
+{
+ lyxview_.getLyXFunc().dispatch(fr, verbose);
+}
+
+
+void Kernel::updateDialog(string const & name) const
+{
+ dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
+}
+
+
+void Kernel::disconnect(string const & name) const
+{
+ lyxview_.getDialogs().disconnect(name);
+}
+
+bool Kernel::isBufferAvailable() const
+{
+ if (!lyxview_.view().get())
+ return false;
+ return lyxview_.view()->available();
+}
+
+
+bool Kernel::isBufferReadonly() const
+{
+ if (!lyxview_.buffer())
+ return true;
+ return lyxview_.buffer()->isReadonly();
+}
+
+
+Kernel::DocTypes Kernel::docType() const
+{
+ if (!buffer())
+ return LATEX;
+
+ if (buffer()->isLatex())
+ return LATEX;
+ if (buffer()->isLiterate())
+ return LITERATE;
+ if (buffer()->isLinuxDoc())
+ return LINUXDOC;
+
+ return DOCBOOK;
+}
+
+BufferView * Kernel::bufferview()
+{
+ return lyxview_.view().get();
+}
+
+
+BufferView const * Kernel::bufferview() const
+{
+ return lyxview_.view().get();
+}
+
+
+Buffer * Kernel::buffer()
+{
+ return lyxview_.buffer();
+}
+
+
+Buffer const * Kernel::buffer() const
+{
+ return lyxview_.buffer();
+}
--- /dev/null
+// -*- C++ -*-
+
+#ifndef KERNEL_H
+#define KERNEL_H
+
+
+#include "LString.h"
+
+
+class Buffer;
+class BufferView;
+class FuncRequest;
+class LyXView;
+
+
+class Kernel {
+public:
+ ///
+ enum DocTypes {
+ ///
+ LATEX,
+ ///
+ LITERATE,
+ ///
+ LINUXDOC,
+ ///
+ DOCBOOK
+ };
+
+ ///
+ Kernel(LyXView &);
+ ///
+ void dispatch(FuncRequest const &, bool verbose = false) const;
+ /** The Dialog has received a request from the user to update
+ its contents. It must, therefore, ask the kernel to provide
+ this information to Dialog 'name'.
+ */
+ void updateDialog(string const & name) const;
+ ///
+ void disconnect(string const & name) const;
+ ///
+ bool isBufferAvailable() const;
+ ///
+ bool isBufferReadonly() const;
+ ///
+ DocTypes docType() const;
+ ///
+ LyXView & lyxview() { return lyxview_; }
+ ///
+ LyXView const & lyxview() const { return lyxview_; }
+ ///
+ Buffer * buffer();
+ ///
+ Buffer const * buffer() const;
+ ///
+ BufferView * bufferview();
+ ///
+ BufferView const * bufferview() const;
+
+private:
+ LyXView & lyxview_;
+};
+
+
+#endif // KERNEL_H
EXTRA_DIST = ButtonController.tmpl ControlDialog.tmpl ControlInset.tmpl
libcontrollers_la_SOURCES= \
+ Dialog.C \
+ Dialog.h \
+ Kernel.C \
+ Kernel.h \
biblio.C \
biblio.h \
character.C \
#include <config.h>
-
#include "Dialogs_impl.h"
-Dialogs::Dialogs(LyXView & lv)
- : pimpl_(new Impl(lv, *this))
-{
- // reduce the number of connections needed in
- // dialogs by a simple connection here.
- hideAll.connect(hideBufferDependent);
-}
-
-Dialogs::~Dialogs()
-{}
-
-
-void Dialogs::toggleTooltips()
+void Dialogs::init_pimpl()
{
- Tooltips::toggleEnabled();
+ pimpl_ = new Impl(lyxview_, *this);
}
-/// Are the tooltips on or off?
-bool Dialogs::tooltipsEnabled()
+Dialogs::~Dialogs()
{
- return Tooltips::enabled();
+ delete pimpl_;
}
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: aboutlyx(lv, d),
- bibitem(lv, d),
- bibtex(lv, d),
character(lv, d),
changes(lv, d),
- citation(lv, d),
document(lv, d),
- error(lv, d),
- ert(lv, d),
external(lv, d),
file(lv, d),
floats(lv, d),
forks(lv, d),
graphics(lv, d),
include(lv, d),
- index(lv, d),
logfile(lv, d),
mathpanel(lv, d),
minipage(lv, d),
preamble(lv, d),
preferences(lv, d),
print(lv, d),
- ref(lv, d),
search(lv, d),
sendto(lv, d),
spellchecker(lv, d),
thesaurus(lv, d),
#endif
- toc(lv, d),
- url(lv, d),
vclogfile(lv, d),
wrap(lv, d)
{}
}
-void Dialogs::showBibitem(InsetCommand * ic)
-{
- pimpl_->bibitem.controller().showInset(ic);
-}
-
-
-void Dialogs::showBibtex(InsetCommand * ic)
-{
- pimpl_->bibtex.controller().showInset(ic);
-}
-
-
void Dialogs::showCharacter()
{
pimpl_->character.controller().show();
}
-void Dialogs::showCitation(InsetCommand * ic)
-{
- pimpl_->citation.controller().showInset(ic);
-}
-
-
-void Dialogs::createCitation(string const & s)
-{
- pimpl_->citation.controller().createInset(s);
-}
-
-
void Dialogs::showDocument()
{
pimpl_->document.controller().show();
}
-void Dialogs::showError(InsetError * ie)
-{
- pimpl_->error.controller().showInset(ie);
-}
-
-
-void Dialogs::showERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
-void Dialogs::updateERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
void Dialogs::showExternal(InsetExternal * ie)
{
pimpl_->external.controller().showInset(ie);
}
-void Dialogs::showIndex(InsetCommand * ic)
-{
- pimpl_->index.controller().showInset(ic);
-}
-
-
-void Dialogs::createIndex()
-{
- pimpl_->index.controller().createInset(string());
-}
-
-
void Dialogs::showLogFile()
{
pimpl_->logfile.controller().show();
}
-void Dialogs::showRef(InsetCommand * ic)
-{
- pimpl_->ref.controller().showInset(ic);
-}
-
-
-void Dialogs::createRef(string const & s)
-{
- pimpl_->ref.controller().createInset(s);
-}
-
-
void Dialogs::showSearch()
{
pimpl_->search.controller().show();
#endif
-void Dialogs::showTOC(InsetCommand * ic)
-{
- pimpl_->toc.controller().showInset(ic);
-}
-
-
-void Dialogs::createTOC(string const & s)
-{
- pimpl_->toc.controller().createInset(s);
-}
-
-
-void Dialogs::showUrl(InsetCommand * ic)
-{
- pimpl_->url.controller().showInset(ic);
-}
-
-
-void Dialogs::createUrl(string const & s)
-{
- pimpl_->url.controller().createInset(s);
-}
-
-
void Dialogs::showVCLogFile()
{
pimpl_->vclogfile.controller().show();
--- /dev/null
+/**
+ * \file qt2/Dialogs3.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 "Dialog.h"
+
+#include "ControlBibitem.h"
+#include "ControlBibtex.h"
+#include "ControlCitation.h"
+#include "ControlError.h"
+#include "ControlERT.h"
+#include "ControlIndex.h"
+#include "ControlRef.h"
+#include "ControlToc.h"
+#include "ControlUrl.h"
+
+#include "FormBibitem.h"
+#include "forms/form_bibitem.h"
+
+#include "FormBibtex.h"
+#include "forms/form_bibtex.h"
+
+#include "FormCitation.h"
+#include "forms/form_citation.h"
+
+#include "GError.h"
+#include "GERT.h"
+
+#include "FormIndex.h"
+#include "forms/form_index.h"
+
+#include "FormRef.h"
+#include "forms/form_ref.h"
+
+#include "FormToc.h"
+#include "forms/form_toc.h"
+
+#include "GUrl.h"
+
+#include "gnomeBC.h"
+#include "ButtonController.h"
+
+
+typedef ButtonController<OkCancelPolicy, gnomeBC>
+ OkCancelBC;
+
+typedef ButtonController<OkCancelReadOnlyPolicy, gnomeBC>
+ OkCancelReadOnlyBC;
+
+typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, gnomeBC>
+ NoRepeatedApplyReadOnlyBC;
+
+
+namespace {
+
+char const * const dialognames[] = { "bibitem", "bibtex", "citation",
+ "error", "ert", "index", "ref",
+ "toc", "url" };
+
+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;
+}
+
+
+Dialog * Dialogs::build(string const & name)
+{
+ if (!isValidName(name))
+ return 0;
+
+ Dialog * dialog = new Dialog(lyxview_, name);
+
+ if (name == "bibitem") {
+ dialog->setController(new ControlBibitem(*dialog));
+ dialog->setView(new FormBibitem(*dialog));
+ dialog->setButtonController(new OkCancelReadOnlyBC);
+ } else if (name == "bibtex") {
+ dialog->setController(new ControlBibtex(*dialog));
+ dialog->setView(new FormBibtex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "citation") {
+ dialog->setController(new ControlCitation(*dialog));
+ dialog->setView(new FormCitation(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "error") {
+ dialog->setController(new ControlError(*dialog));
+ dialog->setView(new GError(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "ert") {
+ dialog->setController(new ControlERT(*dialog));
+ dialog->setView(new GERT(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "index") {
+ dialog->setController(new ControlIndex(*dialog));
+ dialog->setView(new FormIndex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "ref") {
+ dialog->setController(new ControlRef(*dialog));
+ dialog->setView(new FormRef(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "toc") {
+ dialog->setController(new ControlToc(*dialog));
+ dialog->setView(new FormToc(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "url") {
+ dialog->setController(new ControlUrl(*dialog));
+ dialog->setView(new GURL(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ }
+
+ return dialog;
+}
+
+
+void Dialogs::toggleTooltips()
+{
+ Tooltips::toggleEnabled();
+}
+
+
+bool Dialogs::tooltipsEnabled()
+{
+ return Tooltips::enabled();
+}
#include "ControlAboutlyx.h"
#include "GAbout.h"
-#include "ControlBibitem.h"
-#include "FormBibitem.h"
-#include "forms/form_bibitem.h"
-
-#include "ControlBibtex.h"
-#include "FormBibtex.h"
-#include "forms/form_bibtex.h"
-
#include "FormBrowser.h"
#include "forms/form_browser.h"
#include "FormCharacter.h"
#include "forms/form_character.h"
-#include "ControlCitation.h"
-#include "FormCitation.h"
-#include "forms/form_citation.h"
-
#include "ControlChanges.h"
#include "GChanges.h"
typedef GUI<ControlAboutlyx, GAbout, OkCancelPolicy, gnomeBC>
AboutlyxDialog;
-typedef GUI<ControlBibitem, FormBibitem, OkCancelReadOnlyPolicy, xformsBC>
-BibitemDialog;
-
-typedef GUI<ControlBibtex, FormBibtex, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-BibtexDialog;
-
typedef GUI<ControlCharacter, FormCharacter, OkApplyCancelReadOnlyPolicy, xformsBC>
CharacterDialog;
typedef GUI<ControlChanges, GChanges, NoRepeatedApplyReadOnlyPolicy, gnomeBC>
ChangesDialog;
-typedef GUI<ControlCitation, FormCitation, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-CitationDialog;
-
typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
DocumentDialog;
-typedef GUI<ControlError, GErrorDialog, OkCancelPolicy, gnomeBC>
-ErrorDialog;
-
-typedef GUI<ControlERT, GERT, NoRepeatedApplyReadOnlyPolicy, gnomeBC>
-ERTDialog;
-
-typedef GUI<ControlExternal, FormExternal, OkApplyCancelReadOnlyPolicy, xformsBC>
+ypedef GUI<ControlExternal, FormExternal, OkApplyCancelReadOnlyPolicy, xformsBC>
ExternalDialog;
typedef GUI<ControlShowFile, FormShowFile, OkCancelPolicy, xformsBC>
typedef GUI<ControlInclude, FormInclude, OkCancelReadOnlyPolicy, xformsBC>
IncludeDialog;
-typedef GUI<ControlIndex, FormIndex, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-IndexDialog;
-
typedef GUI<ControlLog, GLog, OkCancelPolicy, gnomeBC>
LogFileDialog;
typedef GUI<ControlPrint, FormPrint, OkApplyCancelPolicy, xformsBC>
PrintDialog;
-typedef GUI<ControlRef, FormRef, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-RefDialog;
-
typedef GUI<ControlSearch, FormSearch, NoRepeatedApplyReadOnlyPolicy, xformsBC>
SearchDialog;
ThesaurusDialog;
#endif
-typedef GUI<ControlToc, FormToc, OkCancelPolicy, xformsBC>
-TocDialog;
-
-typedef GUI<ControlUrl, GUrl, NoRepeatedApplyReadOnlyPolicy, gnomeBC>
-UrlDialog;
-
typedef GUI<ControlVCLog, FormVCLog, OkCancelPolicy, xformsBC>
VCLogFileDialog;
Impl(LyXView & lv, Dialogs & d);
AboutlyxDialog aboutlyx;
- BibitemDialog bibitem;
- BibtexDialog bibtex;
CharacterDialog character;
ChangesDialog changes;
- CitationDialog citation;
DocumentDialog document;
- ErrorDialog error;
- ERTDialog ert;
ExternalDialog external;
FileDialog file;
FloatDialog floats;
ForksDialog forks;
GraphicsDialog graphics;
IncludeDialog include;
- IndexDialog index;
LogFileDialog logfile;
MathPanelDialog mathpanel;
MinipageDialog minipage;
PreambleDialog preamble;
PreferencesDialog preferences;
PrintDialog print;
- RefDialog ref;
SearchDialog search;
SendtoDialog sendto;
SpellcheckerDialog spellchecker;
ThesaurusDialog thesaurus;
#endif
- TocDialog toc;
- UrlDialog url;
VCLogFileDialog vclogfile;
WrapDialog wrap;
};
#include <gtkmm/textview.h>
GErrorDialog::GErrorDialog()
- : GnomeCB<ControlError>("GError")
+ : GControlledView<ControlError>("GError")
{}
#include "ControlError.h"
-#include "GnomeBase.h"
+#include "GView.h"
namespace Gtk {
/**
* This class implements the dialog to show error messages.
*/
-class GErrorDialog : public GnomeCB<ControlError> {
+class GErrorDialog : public GControlledView<ControlError> {
public:
///
GErrorDialog();
#include <gtkmm/button.h>
GUrl::GUrl()
- : GnomeCB<ControlUrl>("GUrl")
+ : GControlledView<ControlUrl>("GUrl")
{}
#include "ControlUrl.h"
-#include "GnomeBase.h"
+#include "GView.h"
namespace Gtk {
class Button;
/**
* This class implements the dialog to insert/modify urls.
*/
-class GUrl : public GnomeCB<ControlUrl> {
+class GUrl : public GControlledView<ControlUrl> {
public:
///
GUrl();
--- /dev/null
+/**
+ * \file GView.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Baruch Even
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+
+#include <config.h>
+#include "GView.h"
+#include "support/LAssert.h"
+#include "debug.h"
+#include "support/filetools.h"
+#include "ControlButtons.h"
+#include <glib.h>
+#include <gtkmm/dialog.h>
+
+GView::GView(string const & name)
+ : ViewBase(),
+ updating_(false),
+ file_(name + ".glade"),
+ title_(name),
+ widget_name_(name),
+ xml_(0),
+ dialog_(0)
+{
+ loadXML();
+}
+
+GView::~GView()
+{}
+
+gnomeBC & GView::bc()
+{
+ return static_cast<gnomeBC &>(getController().bc());
+}
+
+void GView::loadXML()
+{
+#ifdef WITH_WARNINGS
+#warning Change this before declaring it production code! (be 20010325)
+#endif
+ string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;");
+
+ string const file = FileOpenSearch(path, file_, "glade");
+
+ if (file.empty()) {
+ lyxerr << "Cannot find glade file. Aborting." << std::endl;
+ lyx::Assert(true);
+ }
+
+ lyxerr[Debug::GUI] << "Glade file to open is " << file << '\n';
+
+ xml_ = Gnome::Glade::Xml::create (file, widget_name_);
+}
+
+
+void GView::show()
+{
+ update();
+ dialog()->show();
+}
+
+
+void GView::hide()
+{
+ dialog()->hide();
+}
+
+bool GView::isValid()
+{
+ return true;
+}
+
+void GView::OKClicked()
+{
+ lyxerr[Debug::GUI] << "GView::OKClicked()\n";
+ getController().OKButton();
+}
+
+void GView::CancelClicked()
+{
+ lyxerr[Debug::GUI] << "GView::CancelClicked()\n";
+ getController().CancelButton();
+}
+
+void GView::ApplyClicked()
+{
+ lyxerr[Debug::GUI] << "GView::ApplyClicked()\n";
+ getController().ApplyButton();
+}
+
+void GView::RestoreClicked()
+{
+ lyxerr[Debug::GUI] << "GView::RestoreClicked()\n";
+ getController().RestoreButton();
+}
+
+void GView::InputChanged()
+{
+ bc().valid(isValid());
+}
+
+Gtk::Dialog * GView::dialog()
+{
+ if (!dialog_)
+ dialog_ = getWidget<Gtk::Dialog>(widget_name_);
+
+ return dialog_;
+}
+
+bool GView::isVisible() const
+{
+ return dialog_ && dialog_->is_visible();
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GView.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Baruch Even
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef GView_H
+#define GView_H
+
+
+#include "gnome_helpers.h"
+
+#include <sigc++/sigc++.h>
+#include <libglademm/xml.h>
+
+#include "ViewBase.h"
+#include "gnomeBC.h"
+
+namespace Gtk {
+ class Dialog;
+};
+
+/**
+ * This is a base class for Gnome dialogs. It handles all the common
+ * work that is needed for all dialogs.
+ */
+class GView : public ViewBase, public SigC::Object {
+public:
+ ///
+ GView(string const & name);
+ ///
+ virtual ~GView();
+
+protected:
+ /// Get the widget named 'name' from the xml representation.
+ template <class T>
+ T* getWidget(const string & name) const;
+
+ /// Get the dialog we use.
+ Gtk::Dialog * dialog();
+
+ /// Show the dialog.
+ void show();
+ /// Hide the dialog.
+ void hide();
+ /// Build the dialog. Also connects signals and prepares it for work.
+ virtual void build() = 0;
+ /// Dialog is valid
+ virtual bool isValid();
+ /// dialog is visible
+ virtual bool isVisible() const;
+ /// Default OK behaviour
+ virtual void OKClicked();
+ /// Default Cancel behaviour
+ virtual void CancelClicked();
+ /// Default Restore behaviour
+ virtual void RestoreClicked();
+ /// Default apply behaviour
+ virtual void ApplyClicked();
+ /// Default changed input behaviour
+ virtual void InputChanged();
+
+ ///
+ gnomeBC & bc();
+
+ /// are we updating ?
+ bool updating_;
+private:
+ /// Loads the glade file to memory.
+ void loadXML();
+
+ /// The glade file name
+ const string file_;
+ /// The widget name
+ const string widget_name_;
+ /// The XML representation of the dialogs.
+ Glib::RefPtr<Gnome::Glade::Xml> xml_;
+
+ /** The dialog we work with, since it is managed by libglade, we do not
+ * need to delete it or destroy it, it will be destroyed with the rest
+ * of the libglade GladeXML structure.
+ */
+ Gtk::Dialog * dialog_;
+
+ /// dialog title, displayed by WM.
+ string title_;
+};
+
+
+template <class T>
+T* GView::getWidget(const string & name) const
+{
+ return dynamic_cast<T*>(xml_->get_widget(name));
+}
+
+/**
+ * This class is used to provide a simple automatic casting of the controller.
+ * We chose not to make GView a template since it has some size and we
+ * have no reason to duplicate it by making it a template.
+ *
+ * Basically the GControlledView<Controller> template instantiates GView and
+ * passes the parameters to it and it also adds the controller() method to
+ * give us a reference to the controller of the correct type (the type is
+ * set by the template parameter).
+*/
+template <class Controller>
+class GControlledView : public GView {
+public:
+ GControlledView(string const & name);
+protected:
+ Controller & controller();
+};
+
+template <class Controller>
+GControlledView<Controller>::GControlledView(string const & name)
+ : GView(name)
+{}
+
+template <class Controller>
+Controller &
+GControlledView<Controller>::controller()
+{
+ return static_cast<Controller &>(getController());
+}
+
+#endif
../xforms/FontInfo.lo \
../xforms/FormAboutlyx.lo \
../xforms/FormBase.lo \
+ ../xforms/FormDialogView.lo \
../xforms/FormBibitem.lo \
../xforms/FormBibtex.lo \
../xforms/FormBrowser.lo \
gnome_helpers.h \
GnomeBase.C \
GnomeBase.h \
+ GView.C \
+ GView.h \
gnomeBC.C \
gnomeBC.h \
lyx_gui.C \
#include <config.h>
-
#include "guiapi.h"
#include "Dialogs.h"
extern "C" {
-void gui_ShowAboutlyx(Dialogs & d)
-{
- d.showAboutlyx();
-}
-
-
-void gui_ShowBibitem(InsetCommand * ic, Dialogs & d)
+void gui_show_dialog(Dialogs * d, char const * name, char const * data)
{
- d.showBibitem(ic);
+ d->show(name, data, 0);
}
-
-
-void gui_ShowBibtex(InsetCommand * ic, Dialogs & d)
+
+void gui_ShowAboutlyx(Dialogs & d)
{
- d.showBibtex(ic);
+ d.showAboutlyx();
}
}
-void gui_ShowCitation(InsetCommand * ic, Dialogs & d)
-{
- d.showCitation(ic);
-}
-
-
-void gui_CreateCitation(string const & s, Dialogs & d)
-{
- d.createCitation(s);
-}
-
-
void gui_ShowDocument(Dialogs & d)
{
d.showDocument();
}
-void gui_ShowError(InsetError * ie, Dialogs & d)
-{
- d.showError(ie);
-}
-
-
-void gui_ShowERT(InsetERT * ie, Dialogs & d)
-{
- d.showERT(ie);
-}
-
-
-void gui_UpdateERT(InsetERT * ie, Dialogs & d)
-{
- d.updateERT(ie);
-}
-
-
void gui_ShowExternal(InsetExternal * ie, Dialogs & d)
{
d.showExternal(ie);
d.showFloat(ifl);
}
+
void gui_ShowWrap(InsetWrap * iw, Dialogs & d)
{
d.showWrap(iw);
}
-void gui_ShowIndex(InsetCommand * ic, Dialogs & d)
-{
- d.showIndex(ic);
-}
-
-
-void gui_CreateIndex(Dialogs & d)
-{
- d.createIndex();
-}
-
-
void gui_ShowLogFile(Dialogs & d)
{
d.showLogFile();
}
-void gui_ShowRef(InsetCommand * ic, Dialogs & d)
-{
- d.showRef(ic);
-}
-
-
-void gui_CreateRef(string const & s, Dialogs & d)
-{
- d.createRef(s);
-}
-
-
void gui_ShowSearch(Dialogs & d)
{
d.showSearch();
}
-void gui_ShowTOC(InsetCommand * ic, Dialogs & d)
-{
- d.showTOC(ic);
-}
-
-
-void gui_CreateTOC(string const & s, Dialogs & d)
-{
- d.createTOC(s);
-}
-
-
-void gui_ShowUrl(InsetCommand * ic, Dialogs & d)
-{
- d.showUrl(ic);
-}
-
-
-void gui_CreateUrl(string const & s, Dialogs & d)
-{
- d.createUrl(s);
-}
-
-
void gui_ShowVCLogFile(Dialogs & d)
{
d.showVCLogFile();
#include "LString.h"
class Dialogs;
-class InsetCommand;
-class InsetError;
-class InsetERT;
class InsetExternal;
class InsetFloat;
class InsetWrap;
extern "C" {
+void gui_show_dialog(Dialogs *, char const * name, char const * data);
+
void gui_ShowAboutlyx(Dialogs &);
-void gui_ShowBibitem(InsetCommand *, Dialogs &);
-void gui_ShowBibtex(InsetCommand *, Dialogs &);
void gui_ShowCharacter(Dialogs &);
void gui_SetUserFreeFont(Dialogs &);
-void gui_ShowCitation(InsetCommand *, Dialogs &);
-void gui_CreateCitation(string const &, Dialogs &);
void gui_ShowDocument(Dialogs &);
-void gui_ShowError(InsetError *, Dialogs &);
-void gui_ShowERT(InsetERT *, Dialogs &);
-void gui_UpdateERT(InsetERT *, Dialogs &);
void gui_ShowExternal(InsetExternal *, Dialogs &);
void gui_ShowFile(string const &, Dialogs &);
void gui_ShowFloat(InsetFloat *, Dialogs &);
-void gui_ShowWrap(InsetWrap *, Dialogs &);
void gui_ShowForks(Dialogs &);
void gui_ShowGraphics(InsetGraphics *, Dialogs &);
void gui_ShowInclude(InsetInclude *, Dialogs &);
-void gui_ShowIndex(InsetCommand *, Dialogs &);
-void gui_CreateIndex(Dialogs &);
void gui_ShowLogFile(Dialogs &);
void gui_ShowMathPanel(Dialogs &);
void gui_ShowMinipage(InsetMinipage *, Dialogs &);
void gui_ShowPreamble(Dialogs &);
void gui_ShowPreferences(Dialogs &);
void gui_ShowPrint(Dialogs &);
-void gui_ShowRef(InsetCommand *, Dialogs &);
-void gui_CreateRef(string const &, Dialogs &);
void gui_ShowSearch(Dialogs &);
void gui_ShowSendto(Dialogs &);
void gui_ShowSpellchecker(Dialogs &);
void gui_ShowTabularCreate(Dialogs &);
void gui_ShowTexinfo(Dialogs &);
void gui_ShowThesaurus(string const &, Dialogs &);
-void gui_ShowTOC(InsetCommand *, Dialogs &);
-void gui_CreateTOC(string const &, Dialogs &);
-void gui_ShowUrl(InsetCommand *, Dialogs &);
-void gui_CreateUrl(string const &, Dialogs &);
void gui_ShowVCLogFile(Dialogs &);
+void gui_ShowWrap(InsetWrap *, Dialogs &);
} // extern "C"
/**
* \file qt2/Dialogs.C
- * Copyright 1995 Matthias Ettrich
* 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 "Dialogs_impl.h"
-Dialogs::Dialogs(LyXView & lv)
- : pimpl_(new Impl(lv, *this))
+void Dialogs::init_pimpl()
{
- // reduce the number of connections needed in
- // dialogs by a simple connection here.
- hideAll.connect(hideBufferDependent);
+ pimpl_ = new Impl(lyxview_, *this);
}
Dialogs::~Dialogs()
-{}
-
-
-void Dialogs::toggleTooltips()
-{}
-
-
-/// Are the tooltips on or off?
-bool Dialogs::tooltipsEnabled()
{
- return false;
+ delete pimpl_;
}
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: aboutlyx(lv, d),
- bibitem(lv, d),
- bibtex(lv, d),
changes(lv, d),
character(lv, d),
- citation(lv, d),
document(lv, d),
- error(lv, d),
- ert(lv, d),
external(lv, d),
file(lv, d),
floats(lv, d),
graphics(lv, d),
include(lv, d),
- index(lv, d),
logfile(lv, d),
minipage(lv, d),
paragraph(lv, d),
prefs(lv, d),
print(lv, d),
- ref(lv, d),
search(lv, d),
sendto(lv, d),
spellchecker(lv, d),
thesaurus(lv, d),
#endif
- toc(lv, d),
- url(lv, d),
vclogfile(lv, d),
wrap(lv, d)
{}
}
-void Dialogs::showBibitem(InsetCommand * ic)
-{
- pimpl_->bibitem.controller().showInset(ic);
-}
-
-
-void Dialogs::showBibtex(InsetCommand * ic)
-{
- pimpl_->bibtex.controller().showInset(ic);
-}
-
-
void Dialogs::showMergeChanges()
{
pimpl_->changes.controller().show();
}
-void Dialogs::showCitation(InsetCommand * ic)
-{
- pimpl_->citation.controller().showInset(ic);
-}
-
-
-void Dialogs::createCitation(string const & s)
-{
- pimpl_->citation.controller().createInset(s);
-}
-
-
void Dialogs::showDocument()
{
pimpl_->document.controller().show();
}
-void Dialogs::showError(InsetError * ie)
-{
- pimpl_->error.controller().showInset(ie);
-}
-
-
-void Dialogs::showERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
-void Dialogs::updateERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
void Dialogs::showExternal(InsetExternal * ie)
{
pimpl_->external.controller().showInset(ie);
}
-void Dialogs::showIndex(InsetCommand * ic)
-{
- pimpl_->index.controller().showInset(ic);
-}
-
-
-void Dialogs::createIndex()
-{
- pimpl_->index.controller().createInset("index");
-}
-
-
void Dialogs::showLogFile()
{
pimpl_->logfile.controller().show();
}
-void Dialogs::showRef(InsetCommand * ic)
-{
- pimpl_->ref.controller().showInset(ic);
-}
-
-
-void Dialogs::createRef(string const & s)
-{
- pimpl_->ref.controller().createInset(s);
-}
-
-
void Dialogs::showSearch()
{
pimpl_->search.controller().show();
#endif
-void Dialogs::showTOC(InsetCommand * ic)
-{
- pimpl_->toc.controller().showInset(ic);
-}
-
-
-void Dialogs::createTOC(string const & s)
-{
- pimpl_->toc.controller().createInset(s);
-}
-
-
-void Dialogs::showUrl(InsetCommand * ic)
-{
- pimpl_->url.controller().showInset(ic);
-}
-
-
-void Dialogs::createUrl(string const & s)
-{
- pimpl_->url.controller().createInset(s);
-}
-
-
void Dialogs::showVCLogFile()
{
pimpl_->vclogfile.controller().show();
--- /dev/null
+/**
+ * \file qt2/Dialogs3.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 "Dialog.h"
+
+#include "ControlBibitem.h"
+#include "ControlBibtex.h"
+#include "ControlCitation.h"
+#include "ControlError.h"
+#include "ControlERT.h"
+#include "ControlIndex.h"
+#include "ControlRef.h"
+#include "ControlToc.h"
+#include "ControlUrl.h"
+
+#include "QBibitem.h"
+#include "QBibitemDialog.h"
+#include "QBibtex.h"
+#include "QBibtexDialog.h"
+#include "QCitation.h"
+#include "QCitationDialog.h"
+#include "QError.h"
+#include "QErrorDialog.h"
+#include "QERT.h"
+#include "QERTDialog.h"
+// Here would be an appropriate point to lecture on the evils
+// of the Qt headers, those most fucked up of disgusting ratholes.
+// But I won't.
+#undef signals
+#include "QIndex.h"
+#include "QIndexDialog.h"
+#include "QRef.h"
+#include "QRefDialog.h"
+#include "QToc.h"
+#include "QTocDialog.h"
+#include "QURL.h"
+#include "QURLDialog.h"
+
+#include "Qt2BC.h"
+#include "ButtonController.h"
+
+
+typedef ButtonController<OkCancelPolicy, Qt2BC>
+ OkCancelBC;
+
+typedef ButtonController<OkCancelReadOnlyPolicy, Qt2BC>
+ OkCancelReadOnlyBC;
+
+typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
+ NoRepeatedApplyReadOnlyBC;
+
+
+namespace {
+
+char const * const dialognames[] = { "bibitem", "bibtex", "citation",
+ "error", "ert", "index", "ref",
+ "toc", "url" };
+
+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;
+}
+
+
+Dialog * Dialogs::build(string const & name)
+{
+ if (!isValidName(name))
+ return 0;
+
+ Dialog * dialog = new Dialog(lyxview_, name);
+
+ if (name == "bibitem") {
+ dialog->setController(new ControlBibitem(*dialog));
+ dialog->setView(new QBibitem(*dialog));
+ dialog->setButtonController(new OkCancelReadOnlyBC);
+ } else if (name == "bibtex") {
+ dialog->setController(new ControlBibtex(*dialog));
+ dialog->setView(new QBibtex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "citation") {
+ dialog->setController(new ControlCitation(*dialog));
+ dialog->setView(new QCitation(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "error") {
+ dialog->setController(new ControlError(*dialog));
+ dialog->setView(new QError(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "ert") {
+ dialog->setController(new ControlERT(*dialog));
+ dialog->setView(new QERT(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "index") {
+ dialog->setController(new ControlIndex(*dialog));
+ dialog->setView(new QIndex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "ref") {
+ dialog->setController(new ControlRef(*dialog));
+ dialog->setView(new QRef(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "toc") {
+ dialog->setController(new ControlToc(*dialog));
+ dialog->setView(new QToc(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "url") {
+ dialog->setController(new ControlUrl(*dialog));
+ dialog->setView(new QURL(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ }
+
+ return dialog;
+}
+
+
+void Dialogs::toggleTooltips()
+{}
+
+
+/// Are the tooltips on or off?
+bool Dialogs::tooltipsEnabled()
+{
+ return false;
+}
#include "controllers/GUI.h"
#include "ControlAboutlyx.h"
-#include "ControlBibitem.h"
-#include "ControlBibtex.h"
#include "ControlChanges.h"
#include "ControlCharacter.h"
-#include "ControlCitation.h"
#include "ControlDocument.h"
-#include "ControlError.h"
-#include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlFloat.h"
#include "ControlForks.h"
#include "ControlGraphics.h"
#include "insets/insetgraphicsParams.h"
#include "ControlInclude.h"
-#include "ControlIndex.h"
#include "ControlLog.h"
#include "ControlMinipage.h"
#include "ControlParagraph.h"
#include "ControlPrefs.h"
#include "ControlPrint.h"
-#include "ControlRef.h"
#include "ControlSearch.h"
#include "ControlSendto.h"
#include "ControlShowFile.h"
#include "ControlTabularCreate.h"
#include "ControlTabular.h"
#include "ControlTexinfo.h"
-#include "ControlToc.h"
-#include "ControlUrl.h"
#include "ControlVCLog.h"
#include "ControlWrap.h"
#include "QAbout.h"
#include "QAboutDialog.h"
-#include "QBibitem.h"
-#include "QBibitemDialog.h"
-#include "QBibtex.h"
-#include "QBibtexDialog.h"
#include "QChanges.h"
#include "QChangesDialog.h"
#include "QCharacter.h"
#include "QCharacterDialog.h"
-#include "QCitation.h"
-#include "QCitationDialog.h"
#include "QDocument.h"
#include "QDocumentDialog.h"
-#include "QError.h"
-#include "QErrorDialog.h"
-#include "QERT.h"
-#include "QERTDialog.h"
#include "QExternal.h"
#include "QExternalDialog.h"
#include "QFloat.h"
#include "QGraphicsDialog.h"
#include "QInclude.h"
#include "QIncludeDialog.h"
-#include "QIndex.h"
-#include "QIndexDialog.h"
#include "QLog.h"
#include "QLogDialog.h"
#include "QMinipage.h"
#include "QPrefsDialog.h"
#include "QPrint.h"
#include "QLPrintDialog.h"
-#include "QRef.h"
-#include "QRefDialog.h"
#include "QSearch.h"
#include "QSearchDialog.h"
#include "QSendto.h"
#include "QThesaurusDialog.h"
#endif
-#include "QToc.h"
-#include "QTocDialog.h"
-#include "QURL.h"
-#include "QURLDialog.h"
#include "QVCLog.h"
#include "QVCLogDialog.h"
#include "QWrap.h"
typedef GUI<ControlAboutlyx, QAbout, OkCancelPolicy, Qt2BC>
AboutlyxDialog;
-typedef GUI<ControlBibitem, QBibitem, OkCancelReadOnlyPolicy, Qt2BC>
-BibitemDialog;
-
-typedef GUI<ControlBibtex, QBibtex, OkCancelReadOnlyPolicy, Qt2BC>
-BibtexDialog;
-
typedef GUI<ControlChanges, QChanges, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
ChangesDialog;
typedef GUI<ControlCharacter, QCharacter, OkApplyCancelReadOnlyPolicy, Qt2BC>
CharacterDialog;
-typedef GUI<ControlCitation, QCitation, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-CitationDialog;
-
typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
DocumentDialog;
-typedef GUI<ControlError, QError, OkCancelPolicy, Qt2BC>
-ErrorDialog;
-
-typedef GUI<ControlERT, QERT, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-ERTDialog;
-
typedef GUI<ControlExternal, QExternal, OkApplyCancelReadOnlyPolicy, Qt2BC>
ExternalDialog;
typedef GUI<ControlInclude, QInclude, OkCancelReadOnlyPolicy, Qt2BC>
IncludeDialog;
-typedef GUI<ControlIndex, QIndex, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-IndexDialog;
-
typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
LogFileDialog;
typedef GUI<ControlPrint, QPrint, OkApplyCancelPolicy, Qt2BC>
PrintDialog;
-typedef GUI<ControlRef, QRef, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-RefDialog;
-
typedef GUI<ControlSearch, QSearch, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
SearchDialog;
ThesaurusDialog;
#endif
-typedef GUI<ControlToc, QToc, OkCancelPolicy, Qt2BC>
-TocDialog;
-
-typedef GUI<ControlUrl, QURL, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-UrlDialog;
-
typedef GUI<ControlVCLog, QVCLog, OkCancelPolicy, Qt2BC>
VCLogFileDialog;
Impl(LyXView & lv, Dialogs & d);
AboutlyxDialog aboutlyx;
- BibitemDialog bibitem;
- BibtexDialog bibtex;
ChangesDialog changes;
CharacterDialog character;
- CitationDialog citation;
DocumentDialog document;
- ErrorDialog error;
- ERTDialog ert;
ExternalDialog external;
FileDialog file;
FloatDialog floats;
GraphicsDialog graphics;
IncludeDialog include;
- IndexDialog index;
LogFileDialog logfile;
MinipageDialog minipage;
ParagraphDialog paragraph;
PrefsDialog prefs;
PrintDialog print;
- RefDialog ref;
SearchDialog search;
SendtoDialog sendto;
SpellcheckerDialog spellchecker;
ThesaurusDialog thesaurus;
#endif
- TocDialog toc;
- UrlDialog url;
VCLogFileDialog vclogfile;
WrapDialog wrap;
};
AM_CXXFLAGS = -DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_TRANSLATION
+
libqt2_la_SOURCES = \
+ QDialogView.C \
+ QDialogView.h \
Alert_pimpl.C \
bulletstrings.C bulletstrings.h \
Dialogs.C \
Dialogs2.C \
+ Dialogs3.C \
Dialogs_impl.h \
FileDialog.C \
LyXKeySymFactory.C \
QShowFileDialog.C QShowFileDialog.h \
QSpellcheckerDialog.C QSpellcheckerDialog.h \
Qt2Base.C Qt2Base.h \
+ QDialogView.C QDialogView.h \
QTabularCreateDialog.C QTabularCreateDialog.h \
QTabularDialog.C QTabularDialog.h \
QTexinfoDialog.C QTexinfoDialog.h \
#include "QBibitem.h"
#include "Qt2BC.h"
-typedef Qt2CB<ControlBibitem, Qt2DB<QBibitemDialog> > base_class;
+typedef QController<ControlBibitem, QView<QBibitemDialog> > base_class;
-QBibitem::QBibitem()
- : base_class(qt_("LyX: Insert Bibliography Item"))
+QBibitem::QBibitem(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert Bibliography Item"))
{
}
#define QBIBITEM_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
class ControlBibitem;
class QBibitemDialog;
class QBibitem
- : public Qt2CB<ControlBibitem, Qt2DB<QBibitemDialog> >
+ : public QController<ControlBibitem, QView<QBibitemDialog> >
{
public:
friend class QBibitemDialog;
- QBibitem();
+ QBibitem(Dialog &);
protected:
virtual bool isValid();
private:
using std::vector;
-typedef Qt2CB<ControlBibtex, Qt2DB<QBibtexDialog> > base_class;
+typedef QController<ControlBibtex, QView<QBibtexDialog> > base_class;
-QBibtex::QBibtex()
- : base_class(qt_("BibTeX"))
+QBibtex::QBibtex(Dialog & parent)
+ : base_class(parent, qt_("BibTeX"))
{
}
#define QBIBTEX_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
class ControlBibtex;
class QBibtexDialog;
class QBibtex
- : public Qt2CB<ControlBibtex, Qt2DB<QBibtexDialog> >
+ : public QController<ControlBibtex, QView<QBibtexDialog> >
{
public:
friend class QBibtexDialog;
- QBibtex();
+ QBibtex(Dialog &);
protected:
virtual bool isValid();
private:
using std::sort;
using std::vector;
-typedef Qt2CB<ControlCitation, Qt2DB<QCitationDialog> > base_class;
+typedef QController<ControlCitation, QView<QCitationDialog> > base_class;
-QCitation::QCitation()
- : base_class(qt_("LyX: Insert Citation"))
+QCitation::QCitation(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert Citation"))
{}
citekeys.clear();
bibkeys.clear();
- Qt2Base::hide();
+ QDialogView::hide();
}
#define QCITATION_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
+
class QListBox;
class ControlCitation;
class QCitationDialog;
-class QCitation
- : public Qt2CB<ControlCitation, Qt2DB<QCitationDialog> >
+class QCitation : public QController<ControlCitation, QView<QCitationDialog> >
{
public:
friend class QCitationDialog;
///
- QCitation();
+ QCitation(Dialog &);
private:
///
enum State {
--- /dev/null
+/**
+ * \file QDialogView.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 <qdialog.h>
+#include <qapplication.h>
+
+#include "debug.h"
+#include "QtLyXView.h"
+#include "Dialogs.h"
+#include "QDialogView.h"
+#include "Qt2BC.h"
+#include "support/LAssert.h"
+
+
+QDialogView::QDialogView(Dialog & parent, QString const & t)
+ : Dialog::View(parent), updating_(false), title_(t)
+{}
+
+
+Qt2BC & QDialogView::bc()
+{
+ return static_cast<Qt2BC &>(dialog().bc());
+}
+
+
+bool QDialogView::isVisible() const
+{
+ return form() && form()->isVisible();
+}
+
+
+bool QDialogView::readOnly() const
+{
+ return kernel().isBufferReadonly();
+}
+
+
+void QDialogView::show()
+{
+ if (!form()) {
+ build();
+ }
+
+ form()->setMinimumSize(form()->sizeHint());
+
+ update(); // make sure its up-to-date
+
+ if (form()->isVisible()) {
+ form()->raise();
+ } else {
+ form()->setCaption(title_);
+ form()->show();
+ }
+}
+
+
+void QDialogView::hide()
+{
+ if (form() && form()->isVisible())
+ form()->hide();
+}
+
+
+bool QDialogView::isValid()
+{
+ return true;
+}
+
+
+void QDialogView::changed()
+{
+ if (updating_)
+ return;
+
+ if (isValid())
+ bc().valid();
+ else
+ bc().invalid();
+}
+
+
+void QDialogView::slotWMHide()
+{
+ dialog().CancelButton();
+}
+
+
+void QDialogView::slotApply()
+{
+ dialog().ApplyButton();
+}
+
+
+void QDialogView::slotOK()
+{
+ dialog().OKButton();
+}
+
+
+void QDialogView::slotClose()
+{
+ dialog().CancelButton();
+}
+
+
+void QDialogView::slotRestore()
+{
+ dialog().RestoreButton();
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file QDialogView.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 QDIALOGVIEW_H
+#define QDIALOGVIEW_H
+
+
+#include "Dialog.h"
+#include <boost/scoped_ptr.hpp>
+
+#include <qfont.h>
+#include <qdialog.h>
+#include <qobject.h>
+#include <qapplication.h>
+
+class Qt2BC;
+
+/** This class is an Qt2 GUI base class.
+ */
+class QDialogView : public QObject, public Dialog::View {
+ Q_OBJECT
+public:
+ ///
+ QDialogView(Dialog &, QString const &);
+ ///
+ virtual ~QDialogView() {}
+ ///
+ bool readOnly() const;
+
+protected:
+ /// build the actual dialog
+ virtual void build_dialog() = 0;
+ ///
+ virtual void build() = 0;
+ /// Hide the dialog.
+ virtual void hide();
+ /// Create the dialog if necessary, update it and display it.
+ virtual void show();
+ /// update the dialog's contents
+ virtual void update_contents() = 0;
+ ///
+ virtual bool isVisible() const;
+
+ /// the dialog has changed contents
+ virtual void changed();
+
+ /// is the dialog currently valid ?
+ virtual bool isValid();
+
+ ///
+ Qt2BC & bc();
+
+ /// are we updating ?
+ bool updating_;
+protected slots:
+ // dialog closed from WM
+ void slotWMHide();
+
+ // Restore button clicked
+ void slotRestore();
+
+ // OK button clicked
+ void slotOK();
+
+ // Apply button clicked
+ void slotApply();
+
+ // Close button clicked
+ void slotClose();
+private:
+ /// Pointer to the actual instantiation of the Qt dialog
+ virtual QDialog * form() const = 0;
+
+private:
+ /// dialog title, displayed by WM.
+ QString title_;
+};
+
+
+template <class GUIDialog>
+class QView: public QDialogView {
+protected:
+ QView(Dialog &, QString const &);
+
+ /// update the dialog
+ virtual void update();
+
+ /// Build the dialog
+ virtual void build();
+
+ /// Pointer to the actual instantiation of the Qt dialog
+ virtual QDialog * form() const;
+
+ /// Real GUI implementation.
+ boost::scoped_ptr<GUIDialog> dialog_;
+
+};
+
+
+template <class GUIDialog>
+QView<GUIDialog>::QView(Dialog & p, QString const & t)
+ : QDialogView(p, t)
+{}
+
+
+template <class GUIDialog>
+QDialog * QView<GUIDialog>::form() const
+{
+ return dialog_.get();
+}
+
+
+template <class GUIDialog>
+void QView<GUIDialog>::update()
+{
+ form()->setUpdatesEnabled(false);
+
+ // protect the BC from unwarranted state transitions
+
+ qApp->processEvents();
+ updating_ = true;
+ update_contents();
+ qApp->processEvents();
+ updating_ = false;
+
+ form()->setUpdatesEnabled(true);
+ form()->update();
+}
+
+
+template <class GUIDialog>
+void QView<GUIDialog>::build()
+{
+ // protect the BC from unwarranted state transitions
+
+ qApp->processEvents();
+ updating_ = true;
+ build_dialog();
+ qApp->processEvents();
+ updating_ = false;
+}
+
+
+template <class Controller, class Base>
+class QController: public Base
+{
+protected:
+ ///
+ QController(Dialog &, QString const &);
+ /// The parent controller
+ Controller & controller();
+ /// The parent controller
+ Controller const & controller() const;
+};
+
+
+template <class Controller, class Base>
+QController<Controller, Base>::QController(Dialog & p, QString const & t)
+ : Base(p, t)
+{}
+
+
+template <class Controller, class Base>
+Controller & QController<Controller, Base>::controller()
+{
+ return static_cast<Controller &>(getController());
+}
+
+
+template <class Controller, class Base>
+Controller const & QController<Controller, Base>::controller() const
+{
+ return static_cast<Controller const &>(getController());
+}
+
+
+#endif // QDIALOGVIEW_H
#include "QERT.h"
#include "Qt2BC.h"
-typedef Qt2CB<ControlERT, Qt2DB<QERTDialog> > base_class;
+typedef QController<ControlERT, QView<QERTDialog> > base_class;
-QERT::QERT()
- : base_class(qt_("LyX: LaTeX Code Settings"))
+QERT::QERT(Dialog & parent)
+ : base_class(parent, qt_("LyX: LaTeX Code Settings"))
{
}
void QERT::apply()
{
- ERTParams & params = controller().params();
-
if (dialog_->openRB->isChecked())
- params.status = InsetERT::Open;
+ controller().setStatus(InsetERT::Open);
else if (dialog_->inlineRB->isChecked())
- params.status = InsetERT::Inlined;
+ controller().setStatus(InsetERT::Inlined);
else
- params.status = InsetERT::Collapsed;
+ controller().setStatus(InsetERT::Collapsed);
}
{
QRadioButton * rb = 0;
- switch (controller().params().status) {
+ switch (controller().status()) {
case InsetERT::Open: rb = dialog_->openRB; break;
case InsetERT::Inlined: rb = dialog_->inlineRB; break;
case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
#define QERT_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
+
class ControlERT;
class QERTDialog;
-class QERT
- : public Qt2CB<ControlERT, Qt2DB<QERTDialog> >
+
+class QERT : public QController<ControlERT, QView<QERTDialog> >
{
public:
friend class QERTDialog;
- QERT();
+ QERT(Dialog &);
private:
/// Apply changes
virtual void apply();
#include "QError.h"
#include "Qt2BC.h"
-typedef Qt2CB<ControlError, Qt2DB<QErrorDialog> > base_class;
+typedef QController<ControlError, QView<QErrorDialog> > base_class;
-QError::QError()
- : base_class(qt_("LyX: LaTeX Error"))
+QError::QError(Dialog & parent)
+ : base_class(parent, qt_("LyX: LaTeX Error"))
{
}
#define QERROR_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
class ControlError;
class QErrorDialog;
class QError
- : public Qt2CB<ControlError, Qt2DB<QErrorDialog> >
+ : public QController<ControlError, QView<QErrorDialog> >
{
public:
friend class QErrorDialog;
- QError();
+ QError(Dialog &);
private:
/// Apply changes
virtual void apply() {}
#include <qlineedit.h>
#include <qpushbutton.h>
-typedef Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > base_class;
+typedef QController<ControlIndex, QView<QIndexDialog> > base_class;
-QIndex::QIndex()
- : base_class(qt_("LyX: Insert Index Entry"))
+QIndex::QIndex(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert Index Entry"))
{
}
#define QINDEX_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
class ControlIndex;
class QIndexDialog;
class QIndex :
- public Qt2CB<ControlIndex, Qt2DB<QIndexDialog> >
+ public QController<ControlIndex, QView<QIndexDialog> >
{
public:
friend class QIndexDialog;
- QIndex();
+ QIndex(Dialog &);
protected:
virtual bool isValid();
private:
using std::endl;
-typedef Qt2CB<ControlRef, Qt2DB<QRefDialog> > base_class;
+typedef QController<ControlRef, QView<QRefDialog> > base_class;
-QRef::QRef()
- : base_class(qt_("LyX: Insert Cross-reference")),
+QRef::QRef(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert Cross-reference")),
sort_(false), at_ref_(false)
{
}
bool QRef::nameAllowed()
{
- return controller().docType() != ControlRef::LATEX &&
- controller().docType() != ControlRef::LITERATE;
+ Kernel::DocTypes doc_type = kernel().docType();
+ return doc_type != Kernel::LATEX &&
+ doc_type != Kernel::LITERATE;
}
bool QRef::typeAllowed()
{
- return controller().docType() != ControlRef::LINUXDOC &&
- controller().docType() != ControlRef::DOCBOOK;
+ Kernel::DocTypes doc_type = kernel().docType();
+ return doc_type != Kernel::LINUXDOC &&
+ doc_type != Kernel::DOCBOOK;
}
#define QREF_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
#include <vector>
#include "LString.h"
class QRef
- : public Qt2CB<ControlRef, Qt2DB<QRefDialog> >
+ : public QController<ControlRef, QView<QRefDialog> >
{
public:
friend class QRefDialog;
- QRef();
+ QRef(Dialog &);
private:
/// apply changes
virtual void apply();
using std::stack;
using std::vector;
-typedef Qt2CB<ControlToc, Qt2DB<QTocDialog> > base_class;
+typedef QController<ControlToc, QView<QTocDialog> > base_class;
-QToc::QToc()
- : base_class(qt_("LyX: Table of Contents")), depth_(1)
+QToc::QToc(Dialog & parent)
+ : base_class(parent, qt_("LyX: Table of Contents")), depth_(1)
{}
#define QTOC_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
#include "toc.h"
class ControlToc;
class QTocDialog;
class QToc :
- public Qt2CB<ControlToc, Qt2DB<QTocDialog> >
+ public QController<ControlToc, QView<QTocDialog> >
{
public:
friend class QTocDialog;
- QToc();
+ QToc(Dialog &);
private:
/// update the listview
void updateToc(int newdepth);
#include <qpushbutton.h>
#include <qlineedit.h>
-typedef Qt2CB<ControlUrl, Qt2DB<QURLDialog> > base_class;
+typedef QController<ControlUrl, QView<QURLDialog> > base_class;
-QURL::QURL()
- : base_class(qt_("LyX: Insert URL"))
+QURL::QURL(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert URL"))
{
}
#define QURL_H
-#include "Qt2Base.h"
+#include "QDialogView.h"
class ControlUrl;
class QURLDialog;
class QURL :
- public Qt2CB<ControlUrl, Qt2DB<QURLDialog> >
+ public QController<ControlUrl, QView<QURLDialog> >
{
public:
friend class QURLDialog;
- QURL();
+ QURL(Dialog &);
protected:
virtual bool isValid();
private:
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * FormDialogView.[Ch]: new base class for the xforms dialogs,
+ deriving from Dialog::View. Otherwise identical to the existing
+ FormBase that derives from ViewBase.
+
+ * Dialogs_impl.h:
+ * Dialogs.C:
+ * Dilaogs2.C: strip out those dialogs that now use the new
+ Dialog class as the platform for an MCV split.
+
+ * Dialogs3.C: new file. Lazy instantiation of those dialogs that
+ now use the new Dialog class.
+
+ * FormBibitem.[Ch]:
+ * FormBibtex.[Ch]:
+ * FormCitation.[Ch]:
+ * FormError.[Ch]:
+ * FormERT.[Ch]:
+ * FormIndex.[Ch]:
+ * FormRef.[Ch]:
+ * FormToc.[Ch]:
+ * FormUrl.[Ch]:
+ * forms/form_bibitem.fd:
+ * forms/form_bibtex.fd:
+ * forms/form_citation.fd:
+ * forms/form_error.fd:
+ * forms/form_ert.fd:
+ * forms/form_index.fd:
+ * forms/form_ref.fd:
+ * forms/form_toc.fd:
+ * forms/form_url.fd: minor changes to reflect the new heirarchy.
+
+ * Makefile.am: add new files.
+
2003-02-22 Alfredo Braunstein <abraunst@libero.it>
* lyx_gui.C (parse_init): added a call to LoaderQueue::setPriority
/**
* \file xforms/Dialogs.C
- * Copyright 1995 Matthias Ettrich
* 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 "Dialogs_impl.h"
-Dialogs::Dialogs(LyXView & lv)
- : pimpl_(new Impl(lv, *this))
-{
- // reduce the number of connections needed in
- // dialogs by a simple connection here.
- hideAll.connect(hideBufferDependent);
-}
-
-Dialogs::~Dialogs()
-{}
-
-
-void Dialogs::toggleTooltips()
+void Dialogs::init_pimpl()
{
- Tooltips::toggleEnabled();
+ pimpl_ = new Impl(lyxview_, *this);
}
-/// Are the tooltips on or off?
-bool Dialogs::tooltipsEnabled()
+Dialogs::~Dialogs()
{
- return Tooltips::enabled();
+ delete pimpl_;
}
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: aboutlyx(lv, d),
- bibitem(lv, d),
- bibtex(lv, d),
changes(lv, d),
character(lv, d),
- citation(lv, d),
document(lv, d),
- error(lv, d),
- ert(lv, d),
external(lv, d),
file(lv, d),
floats(lv, d),
forks(lv, d),
graphics(lv, d),
include(lv, d),
- index(lv, d),
logfile(lv, d),
mathpanel(lv, d),
minipage(lv, d),
preamble(lv, d),
preferences(lv, d),
print(lv, d),
- ref(lv, d),
search(lv, d),
sendto(lv, d),
spellchecker(lv, d),
thesaurus(lv, d),
#endif
- toc(lv, d),
- url(lv, d),
vclogfile(lv, d),
wrap(lv, d)
{}
}
-void Dialogs::showBibitem(InsetCommand * ic)
-{
- pimpl_->bibitem.controller().showInset(ic);
-}
-
-
-void Dialogs::showBibtex(InsetCommand * ic)
-{
- pimpl_->bibtex.controller().showInset(ic);
-}
-
-
void Dialogs::showMergeChanges()
{
pimpl_->changes.controller().show();
}
-void Dialogs::showCitation(InsetCommand * ic)
-{
- pimpl_->citation.controller().showInset(ic);
-}
-
-
-void Dialogs::createCitation(string const & s)
-{
- pimpl_->citation.controller().createInset(s);
-}
-
-
void Dialogs::showDocument()
{
pimpl_->document.controller().show();
}
-void Dialogs::showError(InsetError * ie)
-{
- pimpl_->error.controller().showInset(ie);
-}
-
-
-void Dialogs::showERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
-void Dialogs::updateERT(InsetERT * ie)
-{
- pimpl_->ert.controller().showInset(ie);
-}
-
-
void Dialogs::showExternal(InsetExternal * ie)
{
pimpl_->external.controller().showInset(ie);
}
-void Dialogs::showIndex(InsetCommand * ic)
-{
- pimpl_->index.controller().showInset(ic);
-}
-
-
-void Dialogs::createIndex()
-{
- pimpl_->index.controller().createInset("index");
-}
-
-
void Dialogs::showLogFile()
{
pimpl_->logfile.controller().show();
}
-void Dialogs::showRef(InsetCommand * ic)
-{
- pimpl_->ref.controller().showInset(ic);
-}
-
-
-void Dialogs::createRef(string const & s)
-{
- pimpl_->ref.controller().createInset(s);
-}
-
-
void Dialogs::showSearch()
{
pimpl_->search.controller().show();
#endif
-void Dialogs::showTOC(InsetCommand * ic)
-{
- pimpl_->toc.controller().showInset(ic);
-}
-
-
-void Dialogs::createTOC(string const & s)
-{
- pimpl_->toc.controller().createInset(s);
-}
-
-
-void Dialogs::showUrl(InsetCommand * ic)
-{
- pimpl_->url.controller().showInset(ic);
-}
-
-
-void Dialogs::createUrl(string const & s)
-{
- pimpl_->url.controller().createInset(s);
-}
-
-
void Dialogs::showVCLogFile()
{
pimpl_->vclogfile.controller().show();
--- /dev/null
+/**
+ * \file xforms/Dialogs3.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 "Dialog.h"
+
+#include "Tooltips.h"
+
+#include "ControlBibitem.h"
+#include "FormBibitem.h"
+#include "forms/form_bibitem.h"
+
+#include "ControlBibtex.h"
+#include "FormBibtex.h"
+#include "forms/form_bibtex.h"
+
+#include "ControlCitation.h"
+#include "FormCitation.h"
+#include "forms/form_citation.h"
+
+#include "ControlError.h"
+#include "FormError.h"
+#include "forms/form_error.h"
+
+#include "ControlERT.h"
+#include "FormERT.h"
+#include "forms/form_ert.h"
+
+#include "ControlIndex.h"
+#include "FormIndex.h"
+#include "forms/form_index.h"
+
+#include "ControlRef.h"
+#include "FormRef.h"
+#include "forms/form_ref.h"
+
+#include "ControlToc.h"
+#include "FormToc.h"
+#include "forms/form_toc.h"
+
+#include "ControlUrl.h"
+#include "FormUrl.h"
+#include "forms/form_url.h"
+
+#include "xformsBC.h"
+#include "ButtonController.h"
+
+
+typedef ButtonController<OkCancelPolicy, xformsBC>
+ OkCancelBC;
+
+typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC>
+ OkCancelReadOnlyBC;
+
+typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
+ NoRepeatedApplyReadOnlyBC;
+
+
+namespace {
+
+// char const * const dialognames[] = { "bibitem", "bibtex", "citation",
+// "error", "ert", "external", "float",
+// "graphics", "include", "index",
+// "minipage", "ref", "tabular", "toc",
+// "url", "wrap" };
+char const * const dialognames[] = { "bibitem", "bibtex", "citation",
+ "error", "ert", "index", "ref",
+ "toc", "url" };
+
+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;
+}
+
+
+Dialog * Dialogs::build(string const & name)
+{
+ if (!isValidName(name))
+ return 0;
+
+ Dialog * dialog = new Dialog(lyxview_, name);
+
+ if (name == "bibitem") {
+ dialog->setController(new ControlBibitem(*dialog));
+ dialog->setView(new FormBibitem(*dialog));
+ dialog->setButtonController(new OkCancelReadOnlyBC);
+ } else if (name == "bibtex") {
+ dialog->setController(new ControlBibtex(*dialog));
+ dialog->setView(new FormBibtex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "citation") {
+ dialog->setController(new ControlCitation(*dialog));
+ dialog->setView(new FormCitation(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "error") {
+ dialog->setController(new ControlError(*dialog));
+ dialog->setView(new FormError(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "ert") {
+ dialog->setController(new ControlERT(*dialog));
+ dialog->setView(new FormERT(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "index") {
+ dialog->setController(new ControlIndex(*dialog));
+ dialog->setView(new FormIndex(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "ref") {
+ dialog->setController(new ControlRef(*dialog));
+ dialog->setView(new FormRef(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "toc") {
+ dialog->setController(new ControlToc(*dialog));
+ dialog->setView(new FormToc(*dialog));
+ dialog->setButtonController(new OkCancelBC);
+ } else if (name == "url") {
+ dialog->setController(new ControlUrl(*dialog));
+ dialog->setView(new FormUrl(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ }
+
+ return dialog;
+}
+
+
+void Dialogs::toggleTooltips()
+{
+ Tooltips::toggleEnabled();
+}
+
+
+/// Are the tooltips on or off?
+bool Dialogs::tooltipsEnabled()
+{
+ return Tooltips::enabled();
+}
#include "FormAboutlyx.h"
#include "forms/form_aboutlyx.h"
-#include "ControlBibitem.h"
-#include "FormBibitem.h"
-#include "forms/form_bibitem.h"
-
-#include "ControlBibtex.h"
-#include "FormBibtex.h"
-#include "forms/form_bibtex.h"
-
#include "FormBrowser.h"
#include "forms/form_browser.h"
#include "FormCharacter.h"
#include "forms/form_character.h"
-#include "ControlCitation.h"
-#include "FormCitation.h"
-#include "forms/form_citation.h"
-
#include "ControlDocument.h"
#include "FormDocument.h"
#include "forms/form_document.h"
-#include "ControlError.h"
-#include "FormError.h"
-#include "forms/form_error.h"
-
-#include "ControlERT.h"
-#include "FormERT.h"
-#include "forms/form_ert.h"
-
#include "ControlExternal.h"
#include "FormExternal.h"
#include "forms/form_external.h"
#include "FormInclude.h"
#include "forms/form_include.h"
-#include "ControlIndex.h"
-#include "FormIndex.h"
-#include "forms/form_index.h"
-
#include "ControlLog.h"
#include "FormLog.h"
#include "FormPrint.h"
#include "forms/form_print.h"
-#include "ControlRef.h"
-#include "FormRef.h"
-#include "forms/form_ref.h"
-
#include "ControlSearch.h"
#include "FormSearch.h"
#include "forms/form_search.h"
#include "forms/form_thesaurus.h"
#endif
-#include "ControlToc.h"
-#include "FormToc.h"
-#include "forms/form_toc.h"
-
-#include "ControlUrl.h"
-#include "FormUrl.h"
-#include "forms/form_url.h"
-
#include "ControlVCLog.h"
#include "FormVCLog.h"
typedef GUI<ControlAboutlyx, FormAboutlyx, OkCancelPolicy, xformsBC>
AboutlyxDialog;
-typedef GUI<ControlBibitem, FormBibitem, OkCancelReadOnlyPolicy, xformsBC>
-BibitemDialog;
-
-typedef GUI<ControlBibtex, FormBibtex, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-BibtexDialog;
-
typedef GUI<ControlChanges, FormChanges, NoRepeatedApplyReadOnlyPolicy, xformsBC>
ChangesDialog;
typedef GUI<ControlCharacter, FormCharacter, OkApplyCancelReadOnlyPolicy, xformsBC>
CharacterDialog;
-typedef GUI<ControlCitation, FormCitation, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-CitationDialog;
-
typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
DocumentDialog;
-typedef GUI<ControlError, FormError, OkCancelPolicy, xformsBC>
-ErrorDialog;
-
-typedef GUI<ControlERT, FormERT, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-ERTDialog;
-
typedef GUI<ControlExternal, FormExternal, OkApplyCancelReadOnlyPolicy, xformsBC>
ExternalDialog;
typedef GUI<ControlInclude, FormInclude, OkCancelReadOnlyPolicy, xformsBC>
IncludeDialog;
-typedef GUI<ControlIndex, FormIndex, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-IndexDialog;
-
typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC>
LogFileDialog;
typedef GUI<ControlPrint, FormPrint, OkApplyCancelPolicy, xformsBC>
PrintDialog;
-typedef GUI<ControlRef, FormRef, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-RefDialog;
-
typedef GUI<ControlSearch, FormSearch, NoRepeatedApplyReadOnlyPolicy, xformsBC>
SearchDialog;
ThesaurusDialog;
#endif
-typedef GUI<ControlToc, FormToc, OkCancelPolicy, xformsBC>
-TocDialog;
-
-typedef GUI<ControlUrl, FormUrl, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-UrlDialog;
-
typedef GUI<ControlVCLog, FormVCLog, OkCancelPolicy, xformsBC>
VCLogFileDialog;
Impl(LyXView & lv, Dialogs & d);
AboutlyxDialog aboutlyx;
- BibitemDialog bibitem;
- BibtexDialog bibtex;
ChangesDialog changes;
CharacterDialog character;
- CitationDialog citation;
DocumentDialog document;
- ErrorDialog error;
- ERTDialog ert;
ExternalDialog external;
FileDialog file;
FloatDialog floats;
ForksDialog forks;
GraphicsDialog graphics;
IncludeDialog include;
- IndexDialog index;
LogFileDialog logfile;
MathPanelDialog mathpanel;
MinipageDialog minipage;
PreambleDialog preamble;
PreferencesDialog preferences;
PrintDialog print;
- RefDialog ref;
SearchDialog search;
SendtoDialog sendto;
SpellcheckerDialog spellchecker;
ThesaurusDialog thesaurus;
#endif
- TocDialog toc;
- UrlDialog url;
VCLogFileDialog vclogfile;
WrapDialog wrap;
};
#include "gettext.h"
#include "support/lstrings.h" // compare
-typedef FormCB<ControlBibitem, FormDB<FD_bibitem> > base_class;
+typedef FormController<ControlBibitem, FormView<FD_bibitem> > base_class;
-FormBibitem::FormBibitem()
- : base_class(_("Bibliography Entry"))
+FormBibitem::FormBibitem(Dialog & parent)
+ : base_class(parent, _("Bibliography Entry"))
{}
#define FORMBIBITEM_H
-#include "FormBase.h"
+#include "FormDialogView.h"
class ControlBibitem;
struct FD_bibitem;
/**
* For bibliography entry editing
*/
-class FormBibitem : public FormCB<ControlBibitem, FormDB<FD_bibitem> > {
+class FormBibitem : public FormController<ControlBibitem, FormView<FD_bibitem> > {
public:
///
- FormBibitem();
+ FormBibitem(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();
using std::sort;
-typedef FormCB<ControlBibtex, FormDB<FD_bibtex> > base_class;
+typedef FormController<ControlBibtex, FormView<FD_bibtex> > base_class;
-FormBibtex::FormBibtex()
- : base_class(_("BibTeX Database"))
+FormBibtex::FormBibtex(Dialog & parent)
+ : base_class(parent, _("BibTeX Database"))
{}
// callback for double click in browser
fl_set_browser_dblclick_callback(dialog_->browser_styles,
- C_FormBaseInputCB, 2);
+ C_FormDialogView_InputCB, 2);
// set up the tooltips
string str = _("The database you want to cite from. Insert it "
#define FORMBIBTEX_H
-#include "FormBase.h"
+#include "FormDialogView.h"
class ControlBibtex;
struct FD_bibtex;
/**
* For bibtex database setting
*/
-class FormBibtex : public FormCB<ControlBibtex, FormDB<FD_bibtex> > {
+class FormBibtex : public FormController<ControlBibtex, FormView<FD_bibtex> > {
public:
///
- FormBibtex();
+ FormBibtex(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();
#include "ControlCitation.h"
#include "FormCitation.h"
#include "forms/form_citation.h"
+#include "Kernel.h"
#include "Tooltips.h"
#include "helper_funcs.h"
#include "xforms_helpers.h"
} // namespace anon
-typedef FormCB<ControlCitation, FormDB<FD_citation> > base_class;
+typedef FormController<ControlCitation, FormView<FD_citation> > base_class;
-FormCitation::FormCitation()
- : base_class(_("Citation"))
+FormCitation::FormCitation(Dialog & parent)
+ : base_class(parent, _("Citation"))
{}
citekeys.clear();
bibkeys.clear();
- FormBase::hide();
+ FormDialogView::hide();
}
fl_set_browser_topline(dialog_->browser_cite, n + 1);
}
- if (!controller().bufferIsReadonly()) {
+ if (!kernel().isBufferReadonly()) {
if (cit != citekeys.end()) {
setBibButtons(OFF);
setCiteButtons(ON);
if (sel < 1 || sel > citekeys.size())
return ButtonPolicy::SMI_NOOP;
- if (!controller().bufferIsReadonly()) {
+ if (!kernel().isBufferReadonly()) {
setBibButtons(OFF);
setCiteButtons(ON);
}
#define FORMCITATION_H
-#include "FormBase.h"
+#include "FormDialogView.h"
#include "biblio.h"
/** This class provides an XForms implementation of the Citation Dialog.
class ControlCitation;
struct FD_citation;
-class FormCitation : public FormCB<ControlCitation, FormDB<FD_citation> > {
+class FormCitation : public FormController<ControlCitation, FormView<FD_citation> > {
public:
///
- FormCitation();
+ FormCitation(Dialog &);
private:
///
enum State {
--- /dev/null
+/**
+ * \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 "Dialog.h"
+#include "xformsBC.h"
+#include "xforms_resize.h"
+#include "Tooltips.h"
+#include "xforms_helpers.h" // formatted
+
+#include "gettext.h" // _()
+#include "lyxrc.h"
+#include "BoostFormat.h"
+
+#include "support/LAssert.h"
+#include "support/filetools.h" // LibFileSearch
+
+#include FORMS_H_LOCATION
+
+extern "C" {
+
+// These should be in forms.h but aren't
+void fl_show_tooltip(const char *, int, int);
+
+void fl_hide_tooltip();
+
+// 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),
+ warning_posted_(false), message_widget_(0),
+ minw_(0), minh_(0), allow_resize_(allowResize),
+ title_(t), 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::bc()
+{
+ return static_cast<xformsBC &>(dialog().bc());
+}
+
+
+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, title_.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 (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: " + 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 FormDialogView::hide()
+{
+#if FL_VERSION < 1
+ // Does no harm if none is visible and ensures that the tooltip form
+ // is hidden should the dialog be closed from the keyboard.
+ fl_hide_tooltip();
+#endif
+
+ // 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)
+{
+ lyx::Assert(ob);
+ fl_set_object_prehandler(ob, C_PrehandlerCB);
+}
+
+
+void FormDialogView::setMessageWidget(FL_OBJECT * ob)
+{
+ lyx::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)
+{
+ lyx::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)
+{
+ lyx::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;
+ }
+
+ switch (event) {
+ case FL_ENTER:
+ case FL_LEAVE:
+ if (message_widget_) {
+ // Post feedback as the mouse enters the object,
+ // remove it as the mouse leaves.
+ MessageCB(ob, event);
+ }
+
+#if FL_VERSION < 1
+ if (ob->objclass == FL_TABFOLDER) {
+ // This prehandler is used to work-around an xforms
+ // bug and ensures that the form->x, form->y coords of
+ // the active tabfolder are up to date.
+
+ // The tabfolder itself can be very narrow, being just
+ // the visible border to the tabs.
+ // We thus use both FL_ENTER and FL_LEAVE as flags,
+ // in case the FL_ENTER event is not caught.
+
+ FL_FORM * const folder = fl_get_active_folder(ob);
+ if (folder && folder->window) {
+ fl_get_winorigin(folder->window,
+ &(folder->x), &(folder->y));
+ }
+ }
+#endif
+ break;
+ }
+
+ // Tooltips are not displayed on browser widgets due to an xforms' bug.
+ // I have a fix, but it's not yet in the xforms sources.
+ // This is a work-around:
+ switch (event) {
+ case FL_ENTER:
+ if (ob->objclass == FL_BROWSER &&
+ 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:
+ if (ob->objclass == FL_BROWSER)
+ fl_hide_tooltip();
+ break;
+ }
+}
+
+
+void FormDialogView::postWarning(string const & warning)
+{
+ warning_posted_ = true;
+ postMessage(warning);
+}
+
+
+void FormDialogView::clearMessage()
+{
+ lyx::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)
+{
+ lyx::Assert(message_widget_);
+
+ int const width = message_widget_->w - 10;
+#if USE_BOOST_FORMAT
+ boost::format fmter = warning_posted_ ?
+ boost::format(_("WARNING! %1$s")) :
+ boost::format("%1$s");
+
+ string const str = formatted(boost::io::str(fmter % message),
+ width, FL_NORMAL_SIZE);
+#else
+ string const tmp = warning_posted_ ?
+ _("WARNING!") + string(" ") + message :
+ message;
+
+ string const str = formatted(tmp, width, FL_NORMAL_SIZE);
+#endif
+
+ 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)
+{
+ lyx::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.
+ lyx::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.
+ lyx::Assert(ob);
+
+ // Don't Assert this one, as it can happen quite naturally when things
+ // are being deleted in the d-tor.
+ //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"
--- /dev/null
+// -*- 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 "LString.h"
+#include <boost/scoped_ptr.hpp>
+#include <X11/Xlib.h> // for Pixmap
+
+class xformsBC;
+class Tooltips;
+
+
+/** This class is an XForms GUI base class.
+ */
+class FormDialogView : public Dialog::View {
+public:
+ ///
+ FormDialogView(Dialog &, 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(string const & warning);
+ /// Reset the message_widget_
+ void clearMessage();
+
+ ///
+ xformsBC & bc();
+
+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 string const getFeedback(FL_OBJECT * /* ob */)
+ { return string(); }
+
+ /// Post the feedback message for ob to message_widget_
+ void postMessage(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_;
+ /// dialog title, displayed by the window manager.
+ string title_;
+ /// 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 &, 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, 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 &, string const &, bool allowResize = true);
+};
+
+
+template <class Controller, class Base>
+FormController<Controller, Base>::FormController(Dialog & p,
+ string const & t, bool resize)
+ : Base(p, t, resize)
+{}
+
+
+template <class Controller, class Base>
+Controller & FormController<Controller, Base>::controller()
+{
+ return static_cast<Controller &>(getController());
+}
+
+
+template <class Controller, class Base>
+Controller const & FormController<Controller, Base>::controller() const
+{
+ return static_cast<Controller const &>(getController());
+}
+
+
+#endif // FORMDIALOGVIEW_H
#include "debug.h"
#include FORMS_H_LOCATION
-typedef FormCB<ControlERT, FormDB<FD_ert> > base_class;
+typedef FormController<ControlERT, FormView<FD_ert> > base_class;
-FormERT::FormERT()
- : base_class(_("ERT Options"))
+FormERT::FormERT(Dialog & parent)
+ : base_class(parent, _("ERT Options"))
{}
void FormERT::apply()
{
if (fl_get_button(dialog_->radio_open))
- controller().params().status = InsetERT::Open;
+ controller().setStatus(InsetERT::Open);
else if (fl_get_button(dialog_->radio_collapsed))
- controller().params().status = InsetERT::Collapsed;
+ controller().setStatus(InsetERT::Collapsed);
else
- controller().params().status = InsetERT::Inlined;
+ controller().setStatus(InsetERT::Inlined);
}
void FormERT::update()
{
- switch (controller().params().status) {
+ switch (controller().status()) {
case InsetERT::Open:
fl_set_button(dialog_->radio_open, 1);
break;
#define FORMERT_H
-#include "FormBase.h"
+#include "FormDialogView.h"
+
class ControlERT;
struct FD_ert;
/** This class provides an XForms implementation of the ERT
Dialog.
*/
-class FormERT
- : public FormCB<ControlERT, FormDB<FD_ert> > {
+class FormERT : public FormController<ControlERT, FormView<FD_ert> > {
public:
///
- FormERT();
+ FormERT(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();
#include "xforms_helpers.h" // formatted
#include FORMS_H_LOCATION
-typedef FormCB<ControlError, FormDB<FD_error> > base_class;
+typedef FormController<ControlError, FormView<FD_error> > base_class;
-FormError::FormError()
- : base_class(_("LaTeX Error"))
+FormError::FormError(Dialog & parent)
+ : base_class(parent, _("LaTeX Error"))
{}
#define FORMERROR_H
-#include "FormBase.h"
+#include "FormDialogView.h"
+
class ControlError;
struct FD_error;
/** This class provides an XForms implementation of the Error Dialog.
*/
-class FormError : public FormCB<ControlError, FormDB<FD_error> > {
+class FormError : public FormController<ControlError, FormView<FD_error> > {
public:
/// Constructor
- FormError();
+ FormError(Dialog &);
private:
/// not needed.
virtual void apply() {}
#include FORMS_H_LOCATION
-typedef FormCB<ControlIndex, FormDB<FD_index> > base_class;
+typedef FormController<ControlIndex, FormView<FD_index> > base_class;
-FormIndex::FormIndex()
- : base_class(_("Index"))
+FormIndex::FormIndex(Dialog & parent)
+ : base_class(parent, _("Index"))
{}
#define FORMINDEX_H
-#include "FormBase.h"
+#include "FormDialogView.h"
class ControlIndex;
struct FD_index;
/** This class provides an XForms implementation of the Index Dialog.
*/
-class FormIndex : public FormCB<ControlIndex, FormDB<FD_index> > {
+class FormIndex : public FormController<ControlIndex, FormView<FD_index> > {
public:
///
- FormIndex();
+ FormIndex(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();
using std::sort;
using std::vector;
-typedef FormCB<ControlRef, FormDB<FD_ref> > base_class;
+typedef FormController<ControlRef, FormView<FD_ref> > base_class;
-FormRef::FormRef()
- : base_class(_("Reference")),
+FormRef::FormRef(Dialog & parent)
+ : base_class(parent, _("Reference")),
at_ref_(false)
{}
switch_go_button();
// Name is irrelevant to LaTeX/Literate documents
- if (controller().docType() == ControlRef::LATEX ||
- controller().docType() == ControlRef::LITERATE) {
+ Kernel::DocTypes 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 (controller().docType() == ControlRef::LINUXDOC ||
- controller().docType() == ControlRef::DOCBOOK) {
+ if (doctype == Kernel::LINUXDOC || doctype == Kernel::DOCBOOK) {
fl_set_choice(dialog_->choice_format, 1);
setEnabled(dialog_->choice_format, false);
} else {
if (sel < 1 || sel > refs_.size())
return ButtonPolicy::SMI_NOOP;
- if (!controller().bufferIsReadonly()) {
+ if (!kernel().isBufferReadonly()) {
string s = fl_get_browser_line(dialog_->browser_refs, sel);
fl_set_input(dialog_->input_ref, s.c_str());
}
#define FORMREF_H
-#include "FormBase.h"
+#include "FormDialogView.h"
class ControlRef;
struct FD_ref;
/** This class provides an XForms implementation of the FormRef Dialog.
*/
-class FormRef : public FormCB<ControlRef, FormDB<FD_ref> > {
+class FormRef : public FormController<ControlRef, FormView<FD_ref> > {
public:
///
- FormRef();
+ FormRef(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();
using std::endl;
-typedef FormCB<ControlToc, FormDB<FD_toc> > base_class;
+typedef FormController<ControlToc, FormView<FD_toc> > base_class;
-FormToc::FormToc()
- : base_class(_("Table of Contents"))
+FormToc::FormToc(Dialog & parent)
+ : base_class(parent, _("Table of Contents"))
{}
#define FORMTOC_H
-#include "FormBase.h"
+#include "FormDialogView.h"
#include "toc.h"
class ControlToc;
/** This class provides an XForms implementation of the FormToc Dialog.
*/
-class FormToc : public FormCB<ControlToc, FormDB<FD_toc> > {
+class FormToc : public FormController<ControlToc, FormView<FD_toc> > {
public:
///
- FormToc();
+ FormToc(Dialog &);
private:
/// not needed
virtual void apply() {}
#include "forms/form_url.h"
#include FORMS_H_LOCATION
-typedef FormCB<ControlUrl, FormDB<FD_url> > base_class;
+typedef FormController<ControlUrl, FormView<FD_url> > base_class;
-FormUrl::FormUrl()
- : base_class(_("Url"))
+FormUrl::FormUrl(Dialog & parent)
+ : base_class(parent, _("Url"))
{}
#define FORMURL_H
-#include "FormBase.h"
+#include "FormDialogView.h"
class ControlUrl;
struct FD_url;
/** This class provides an XForms implementation of the Url Dialog.
*/
-class FormUrl : public FormCB<ControlUrl, FormDB<FD_url> > {
+class FormUrl : public FormController<ControlUrl, FormView<FD_url> > {
public:
///
- FormUrl();
+ FormUrl(Dialog &);
private:
/// Apply from dialog (modify or create inset)
virtual void apply();
ColorHandler.h \
Dialogs.C \
Dialogs2.C \
+ Dialogs3.C \
Dialogs_impl.h \
DropDown.h \
DropDown.C \
FormAboutlyx.h \
FormBase.C \
FormBase.h \
+ FormDialogView.C \
+ FormDialogView.h \
FormBibitem.C \
FormBibitem.h \
FormBibtex.C \
XWorkArea.C
libxforms.la: $(libxforms_la_OBJECTS) $(libxforms_la_DEPENDENCIES)
-
-# just copied from old lyx repository
-#dist-hook:
-# for subdir in $(LYXDATADIRS) ; do \
-# test -d $(distdir)/$$subdir \
-# || mkdir $(distdir)/$$subdir \
-# || exit 1; \
-# chmod 777 $(distdir)/$$subdir; \
-# list=`(cd $(srcdir)/$$subdir && ls -1 | grep -v CVS)`; \
-# echo $$list ; \
-# for fil in $$list ; do \
-# cp -p $(srcdir)/$$subdir/$$fil $(distdir)/$$subdir ; \
-# done ; \
-# done
case FL_KEYPRESS:
{
lyxerr[Debug::WORKAREA] << "Workarea event: KEYPRESS" << endl;
-
- KeySym keysym = 0;
- char dummy[1];
XKeyEvent * xke = reinterpret_cast<XKeyEvent *>(ev);
- XLookupString(xke, dummy, 1, &keysym, 0);
if (lyxerr.debugging(Debug::KEY)) {
char const * const tmp = XKeysymToString(key);
- char const * const tmp2 = XKeysymToString(keysym);
- string const stm = (tmp ? tmp : string());
- string const stm2 = (tmp2 ? tmp2 : string());
-
- lyxerr << "XWorkArea: Key is `" << stm
- << "' [" << key << "]\n"
- << "XWorkArea: Keysym is `" << stm2
- << "' [" << keysym << ']' << endl;
+ lyxerr << "XWorkArea: Key is `" << tmp
+ << "' [" << key << "]" << endl;
}
- // Note that we need this handling because of a bug
- // in XForms 0.89, if this bug is resolved in the way I hope
- // we can just use the keysym directly without looking
- // at key at all. (Lgb)
- KeySym ret_key = 0;
if (!key) {
- // We might have to add more keysyms here also,
- // we will do that as the issues arise. (Lgb)
- if (keysym == XK_space) {
- ret_key = keysym;
- lyxerr[Debug::KEY] << "Using keysym [A]"
- << endl;
- } else
- break;
- } else {
- // It seems that this was a bit optimistic...
- // With this hacking things seems to be better (Lgb)
- //if (!iscntrl(key)) {
- // ret_key = key;
- // lyxerr[Debug::KEY]
- // << "Using key [B]\n"
- // << "Uchar["
- // << static_cast<unsigned char>(key)
- // << endl;
- //} else {
- ret_key = (keysym ? keysym : key);
- lyxerr[Debug::KEY] << "Using keysym [B]"
- << endl;
- //}
+ lyxerr << "Probably composing" << endl;
+ break;
}
+ KeySym ret_key = key;
unsigned int const ret_state = xke->state;
// If you have a better way to handle "wild-output" of
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_key
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 3
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_label
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 2
==============================
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: button_rescan
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_database
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_style
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_database_browse
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_bibtotoc
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_North FL_South
name: browser_styles
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_style_browse
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
==============================
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_South
name: browser_cite
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_North FL_SouthEast
name: browser_bib
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_add
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_del
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_up
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: button_down
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: button_previous
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: button_next
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_style
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: check_full_author_list
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: check_force_uppercase
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: input_before
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: input_after
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
==============================
resize: FL_RESIZE_NONE
gravity: FL_South FL_South
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
==============================
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_open
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_collapsed
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_inlined
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
==============================
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: input_key
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
==============================
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_SouthEast
name: browser_refs
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: button_update
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: check_sort
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast
name: choice_document
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
align: FL_ALIGN_LEFT
resize: FL_RESIZE_X
gravity: FL_South FL_South
name: input_ref
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_South FL_South
name: choice_format
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: button_go
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
==============================
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_SouthEast
name: browser_toc
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_update
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: choice_toc_type
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
==============================
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_url
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_name
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_html
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
==============================
* insetfloat.C:
* insetwrap.C: TocItem changed API (bug 913)
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * insetcollapsable.[Ch] (cache, edit):
+ * insetbutton.[Ch] (cache, edit): new methods to cache the
+ BufferView in the draw method.
+
+ * insetcommand.[Ch]: implement a new class, InsetCommandMailer, to
+ simplify comunication between InsetCommand-derived classes and
+ the Dialogs.
+
+ * insetbibitem.[Ch]:
+ * insetbibtex.[Ch]:
+ * insetcite.[Ch]:
+ * inseterror.[Ch]:
+ * insetfloatlist.[Ch]:
+ * insetindex.[Ch]:
+ * insetref.[Ch]:
+ * insettoc.[Ch]:
+ * inseturl.[Ch]: small changes to reflect the new interface to the
+ Dialogs code.
+
+ * mailinset.[Ch]: new files. Base class to InsetCommandMailer and
+ other, similar classes.
+
+ * Makefile.am: add new files.
+
2003-02-21 Angus Leeming <leeming@lyx.org>
* updatableinset.h (setView, view): remove.
insettheorem.h
libinsets_la_SOURCES = \
+ mailinset.C \
+ mailinset.h \
ExternalTemplate.C \
ExternalTemplate.h \
inset.C \
#include "lyxlex.h"
#include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
#include "support/lstrings.h"
}
+InsetBibitem::~InsetBibitem()
+{
+ InsetCommandMailer mailer("bibitem", *this);
+ mailer.hideDialog();
+}
+
+
Inset * InsetBibitem::clone(Buffer const &, bool) const
{
InsetBibitem * b = new InsetBibitem(params());
}
-void InsetBibitem::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetBibitem::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showBibitem(this);
+ InsetCommandMailer mailer("bibitem", *this);
+ mailer.showDialog();
}
///
InsetBibitem(InsetCommandParams const &);
///
+ ~InsetBibitem();
+ ///
Inset * clone(Buffer const &, bool same_id = false) const;
/** Currently \bibitem is used as a LyX2.x command,
so we need this method.
#include "insetbibtex.h"
#include "buffer.h"
-#include "BufferView.h"
#include "debug.h"
#include "gettext.h"
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
-
#include "support/filetools.h"
#include "support/path.h"
#include "support/os.h"
{}
+InsetBibtex::~InsetBibtex()
+{
+ InsetCommandMailer mailer("bibtex", *this);
+ mailer.hideDialog();
+}
+
+
string const InsetBibtex::getScreenLabel(Buffer const *) const
{
return _("BibTeX Generated References");
}
-void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetBibtex::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showBibtex(this);
+ InsetCommandMailer mailer("bibtex", *this);
+ mailer.showDialog();
}
///
InsetBibtex(InsetCommandParams const &, bool same_id = false);
///
+ ~InsetBibtex();
+ ///
Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetBibtex(params(), same_id);
}
#include "insetbutton.h"
#include "debug.h"
#include "BufferView.h"
+#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "support/LAssert.h"
#include "lyxfont.h"
int baseline, float & x, bool) const
{
lyx::Assert(bv);
+ cache(bv);
Painter & pain = bv->painter();
// Draw it as a box with the LaTeX text
x += width(bv, font);
}
+
+
+void InsetButton::cache(BufferView * bv) const
+{
+ view_ = bv->owner()->view();
+}
+
+
+BufferView * InsetButton::view() const
+{
+ return view_.get();
+}
#include "inset.h"
#include "LString.h"
+#include <boost/weak_ptr.hpp>
/** Used to provide an inset that looks like a button.
*/
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
protected:
+ ///
+ virtual void cache(BufferView *) const;
+ ///
+ virtual BufferView * view() const;
/// This should provide the text for the button
virtual string const getScreenLabel(Buffer const *) const = 0;
+private:
+ mutable boost::weak_ptr<BufferView> view_;
};
#endif
#include <config.h>
-
#include "insetcite.h"
#include "buffer.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
-#include "frontends/LyXView.h"
-#include "debug.h"
-#include "gettext.h"
#include "frontends/controllers/biblio.h"
-#include "frontends/Dialogs.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
-#include "support/path.h"
-#include "support/os.h"
#include "support/lstrings.h"
-#include "support/LAssert.h"
#include <map>
{}
+InsetCitation::~InsetCitation()
+{
+ InsetCommandMailer mailer("citation", *this);
+ mailer.hideDialog();
+}
+
+
string const InsetCitation::generateLabel(Buffer const * buffer) const
{
string const before = string();
// buffer but doing some real work.
setLoadingBuffer(bv->buffer(), false);
- bv->owner()->getDialogs().showCitation(this);
+ InsetCommandMailer mailer("citation", *this);
+ mailer.showDialog();
}
///
InsetCitation(InsetCommandParams const &, bool same_id = false);
///
+ ~InsetCitation();
+ ///
Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetCitation(params(), same_id);
}
#include "frontends/font_metrics.h"
#include "frontends/Painter.h"
+#include "frontends/LyXView.h"
#include "support/LOstream.h"
#include "support/lstrings.h"
{
inset.addPreview(loader);
}
+
+
+void InsetCollapsable::cache(BufferView * bv) const
+{
+ view_ = bv->owner()->view();
+}
+
+
+BufferView * InsetCollapsable::view() const
+{
+ return view_.get();
+}
+
+
#include "lyxfont.h"
#include "LColor.h"
+#include <boost/weak_ptr.hpp>
+
class Painter;
class LyXText;
class Paragraph;
void addPreview(grfx::PreviewLoader &) const;
protected:
+ ///
+ virtual void cache(BufferView *) const;
+ ///
+ virtual BufferView * view() const;
+
///
int ascent_collapsed() const;
///
bool in_update;
///
mutable bool first_after_edit;
+ ///
+ mutable boost::weak_ptr<BufferView> view_;
};
#endif
#include "insetcommand.h"
#include "debug.h"
#include "frontends/Painter.h"
+#include "Lsstream.h"
+#include "lyxlex.h"
using std::ostream;
using std::endl;
{
return 0;
}
+
+
+InsetCommandMailer::InsetCommandMailer(string const & name,
+ InsetCommand & inset)
+ : name_(name), inset_(inset)
+{}
+
+
+string const InsetCommandMailer::inset2string() const
+{
+ return params2string(inset_.params());
+}
+
+
+void InsetCommandMailer::string2params(string const & in,
+ InsetCommandParams & params)
+{
+ params.setCmdName(string());
+ params.setContents(string());
+ params.setOptions(string());
+
+ if (in.empty())
+ return;
+
+ istringstream data(in);
+ LyXLex lex(0,0);
+ lex.setStream(data);
+
+ params.read(lex);
+}
+
+
+string const
+InsetCommandMailer::params2string(InsetCommandParams const & params)
+{
+ ostringstream data;
+ params.write(data);
+ data << "\\end_inset\n";
+
+ return data.str();
+}
#include "insetbutton.h"
#include "insetcommandparams.h"
-#include <boost/signals/signal0.hpp>
+#include "mailinset.h"
#include <boost/utility.hpp>
// Created by Alejandro 970222
explicit
InsetCommand(InsetCommandParams const &, bool same_id = false);
///
- virtual ~InsetCommand() { hideDialog(); }
- ///
void write(Buffer const *, std::ostream & os) const
{ p_.write(os); }
///
InsetCommandParams const & params() const { return p_; }
///
void setParams(InsetCommandParams const &);
- ///
- boost::signal0<void> hideDialog;
private:
///
InsetCommandParams p_;
};
+
+class InsetCommandMailer : public MailInset {
+public:
+ ///
+ InsetCommandMailer(string const & name, InsetCommand & inset);
+ ///
+ virtual Inset & inset() const { return inset_; }
+ ///
+ virtual string const & name() const { return name_; }
+ ///
+ virtual string const inset2string() const;
+ ///
+ static void string2params(string const &, InsetCommandParams &);
+ ///
+ static string const params2string(InsetCommandParams const &);
+private:
+ ///
+ string const name_;
+ ///
+ InsetCommand & inset_;
+};
+
+
#endif
#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "frontends/Dialogs.h"
+#include "support/LAssert.h"
using std::ostream;
{}
+InsetError::~InsetError()
+{
+ if (view())
+ view()->owner()->getDialogs().hide("error");
+}
+
+
int InsetError::ascent(BufferView *, LyXFont const & font) const
{
LyXFont efont;
void InsetError::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
{
+ lyx::Assert(bv);
+ cache(bv);
+
Painter & pain = bv->painter();
LyXFont efont;
efont.setSize(font.size()).decSize();
void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showError(this);
+ bv->owner()->getDialogs().show("error", getContents(), this);
}
#include "inset.h"
#include "LString.h"
-#include <boost/signals/signal0.hpp>
-
/** Used for error messages from LaTeX runs.
The edit-operation opens a
explicit
InsetError(string const &, bool same_id = false);
///
- ~InsetError() { hideDialog(); }
+ ~InsetError();
///
int ascent(BufferView *, LyXFont const &) const;
///
bool directWrite() const { return true; };
///
string const & getContents() const { return contents; }
- ///
- boost::signal0<void> hideDialog;
private:
///
string contents;
*/
#include <config.h>
-
#include "insetert.h"
#include "insettext.h"
#include "frontends/LyXView.h"
#include "support/LOstream.h"
+#include "support/LAssert.h"
+#include "support/lstrings.h"
using std::ostream;
InsetERT::~InsetERT()
{
- hideDialog();
+ InsetERTMailer mailer(*this);
+ mailer.hideDialog();
}
pos_type const max_length = 15;
pos_type const p_siz = inset.paragraph()->size();
pos_type const n = min(max_length, p_siz);
- int i = 0;
- int j = 0;
+ pos_type i = 0;
+ pos_type j = 0;
for(; i < n && j < p_siz; ++j) {
if (inset.paragraph()->isInset(j))
continue;
void InsetERT::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
{
+ lyx::Assert(bv);
+ cache(bv);
+
Painter & pain = bv->painter();
button_length = width_collapsed();
}
-bool InsetERT::showInsetDialog(BufferView * bv) const
+bool InsetERT::showInsetDialog(BufferView *) const
{
- bv->owner()->getDialogs().showERT(const_cast<InsetERT *>(this));
+ InsetERTMailer mailer(const_cast<InsetERT &>(*this));
+ mailer.showDialog();
return true;
}
}
InsetCollapsable::update(bv, font, reinit);
}
+
+
+InsetERTMailer::InsetERTMailer(InsetERT & inset)
+ : name_("ert"), inset_(inset)
+{}
+
+
+string const InsetERTMailer::inset2string() const
+{
+ return params2string(inset_.status());
+}
+
+
+void InsetERTMailer::string2params(string const & in,
+ InsetERT::ERTStatus & status)
+{
+ status = InsetERT::Collapsed;
+ if (in.empty())
+ return;
+
+ status = static_cast<InsetERT::ERTStatus>(strToInt(in));
+}
+
+
+string const
+InsetERTMailer::params2string(InsetERT::ERTStatus status)
+{
+ return tostr(status);
+}
#include "insetcollapsable.h"
-#include <boost/signals/signal0.hpp>
-
/** A collapsable text inset for LaTeX insertions.
To write full ert (including styles and other insets) in a given
///
EDITABLE editable() const;
///
- boost::signal0<void> hideDialog;
- ///
int latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const;
///
mutable ERTStatus status_;
};
+
+#include "mailinset.h"
+
+class InsetERTMailer : public MailInset {
+public:
+ ///
+ InsetERTMailer(InsetERT & inset);
+ ///
+ virtual Inset & inset() const { return inset_; }
+ ///
+ virtual string const & name() const { return name_; }
+ ///
+ virtual string const inset2string() const;
+ ///
+ static void string2params(string const &, InsetERT::ERTStatus &);
+ ///
+ static string const params2string(InsetERT::ERTStatus);
+private:
+ ///
+ string const name_;
+ ///
+ InsetERT & inset_;
+};
+
+
#endif
}
+InsetFloatList::~InsetFloatList()
+{
+ InsetCommandMailer mailer("toc", *this);
+ mailer.hideDialog();
+}
+
+
string const InsetFloatList::getScreenLabel(Buffer const * buf) const
{
FloatList const & floats = buf->params.getLyXTextClass().floats();
}
-void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetFloatList::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showTOC(this);
+ InsetCommandMailer mailer("toc", *this);
+ mailer.showDialog();
}
///
InsetFloatList(string const & type);
///
+ ~InsetFloatList();
+ ///
Inset * clone(Buffer const &, bool = false) const {
return new InsetFloatList(getCmdName());
}
{}
+InsetIndex::~InsetIndex()
+{
+ InsetCommandMailer mailer("index", *this);
+ mailer.hideDialog();
+}
+
+
string const InsetIndex::getScreenLabel(Buffer const *) const
{
return _("Idx");
}
-void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetIndex::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showIndex(this);
+ InsetCommandMailer mailer("index", *this);
+ mailer.showDialog();
}
///
InsetIndex(InsetCommandParams const &, bool same_id = false);
///
+ ~InsetIndex();
+ ///
virtual Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetIndex(params(), same_id);
}
{}
+InsetRef::~InsetRef()
+{
+ InsetCommandMailer mailer("ref", *this);
+ mailer.hideDialog();
+}
+
+
void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
{
// FuncRequestually trigger dialog with button 3 not 1
if (button == mouse_button::button3)
bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
- else if (button == mouse_button::button1)
- bv->owner()->getDialogs().showRef(this);
+ else if (button == mouse_button::button1) {
+ InsetCommandMailer mailer("ref", *this);
+ mailer.showDialog();
+ }
}
///
InsetRef(InsetCommandParams const &, Buffer const &, bool same_id = false);
///
+ ~InsetRef();
+ ///
virtual Inset * clone(Buffer const & buffer, bool same_id = false) const {
return new InsetRef(params(), buffer, same_id);
}
using std::ostream;
+InsetTOC::InsetTOC(InsetCommandParams const & p, bool same_id)
+ : InsetCommand(p, same_id)
+{}
+
+
+InsetTOC::~InsetTOC()
+{
+ InsetCommandMailer mailer("toc", *this);
+ mailer.hideDialog();
+}
+
+
string const InsetTOC::getScreenLabel(Buffer const *) const
{
string const cmdname(getCmdName());
}
-void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetTOC::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showTOC(this);
+ InsetCommandMailer mailer("toc", *this);
+ mailer.showDialog();
}
class InsetTOC : public InsetCommand {
public:
///
- InsetTOC(InsetCommandParams const & p, bool same_id = false)
- : InsetCommand(p, same_id) {}
+ InsetTOC(InsetCommandParams const &, bool same_id = false);
+ ///
+ ~InsetTOC();
///
virtual Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetTOC(params(), same_id);
{}
-void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
+InsetUrl::~InsetUrl()
{
- bv->owner()->getDialogs().showUrl(this);
+ InsetCommandMailer mailer("url", *this);
+ mailer.hideDialog();
+}
+
+
+void InsetUrl::edit(BufferView *, int, int, mouse_button::state)
+{
+ InsetCommandMailer mailer("url", *this);
+ mailer.showDialog();
}
explicit
InsetUrl(InsetCommandParams const &, bool same_id = false);
///
+ ~InsetUrl();
+ ///
virtual Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetUrl(params(), same_id);
}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file mailinset.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 "mailinset.h"
+#include "inset.h"
+#include "BufferView.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "Lsstream.h"
+
+
+void MailInset::showDialog() const
+{
+ BufferView * bv = inset().view();
+ if (!bv)
+ return;
+
+ bv->owner()->getDialogs().show(name(), inset2string(), &inset());
+}
+
+
+void MailInset::updateDialog() const
+{
+ BufferView * bv = inset().view();
+ if (!bv)
+ return;
+
+ bv->owner()->getDialogs().update(name(), inset2string());
+}
+
+
+void MailInset::hideDialog() const
+{
+ BufferView * bv = inset().view();
+ if (!bv)
+ return;
+
+ bv->owner()->getDialogs().hide(name());
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file mailinset.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 MAILINSET_H
+#define MAILINSET_H
+
+
+#include "LString.h"
+
+
+class Inset;
+
+
+class MailInset {
+public:
+ ///
+ virtual ~MailInset() {};
+ ///
+ void showDialog() const;
+ ///
+ void updateDialog() const;
+ ///
+ void hideDialog() const;
+ ///
+ virtual string const inset2string() const = 0;
+
+protected:
+ ///
+ virtual Inset & inset() const = 0;
+ ///
+ virtual string const & name() const = 0;
+};
+
+
+#endif // MAILINSET_H
#include "ParagraphParameters.h"
#include "insets/insetcommand.h"
+#include "insets/inseterror.h"
+#include "insets/insetert.h"
#include "insets/insettabular.h"
#include "mathed/formulamacro.h"
case LFUN_REF_INSERT:
code = Inset::REF_CODE;
break;
- case LFUN_CITATION_CREATE:
- case LFUN_CITATION_INSERT:
- code = Inset::CITE_CODE;
- break;
- case LFUN_INSERT_BIBTEX:
+ case LFUN_BIBTEX_APPLY:
code = Inset::BIBTEX_CODE;
break;
+ case LFUN_CITATION_APPLY:
+ code = Inset::CITE_CODE;
+ break;
case LFUN_INDEX_INSERT:
code = Inset::INDEX_CODE;
break;
break;
case LFUN_TOCVIEW:
-#if 0
- case LFUN_LOFVIEW:
- case LFUN_LOTVIEW:
- case LFUN_LOAVIEW:
-#endif
{
- InsetCommandParams p;
-
-#if 0
- if (action == LFUN_TOCVIEW)
-#endif
- p.setCmdName("tableofcontents");
-#if 0
- else if (action == LFUN_LOAVIEW)
- p.setCmdName("listof{algorithm}{List of Algorithms}");
- else if (action == LFUN_LOFVIEW)
- p.setCmdName("listoffigures");
- else
- p.setCmdName("listoftables");
-#endif
- owner->getDialogs().createTOC(p.getAsString());
+ InsetCommandParams p("tableofcontents");
+ string const data = InsetCommandMailer::params2string(p);
+ owner->getDialogs().show("toc", data, 0);
break;
}
owner->getDialogs().showMathPanel();
break;
- case LFUN_CITATION_CREATE:
- {
- InsetCommandParams p("cite");
+ case LFUN_DIALOG_SHOW_NEW_INSET: {
+ string const & name = argument;
+ string data;
+ if (name == "bibitem" ||
+ name == "bibtex" ||
+ name == "index" ||
+ name == "ref" ||
+ name == "toc" ||
+ name == "url") {
+ InsetCommandParams p(name);
+ data = InsetCommandMailer::params2string(p);
+ } else if (name == "citation") {
+ InsetCommandParams p("cite");
+ data = InsetCommandMailer::params2string(p);
+// } else if (name == "error" || name == "ert") {
+// // need do nothing special
+ }
+ owner->getDialogs().show(name, data, 0);
+ }
+ break;
- if (!argument.empty()) {
- // This should be set at source, ie when typing
- // "citation-insert foo" in the minibuffer.
- // Question: would pybibliographer also need to be
- // changed. Suspect so. Leave as-is therefore.
- if (contains(argument, "|")) {
- p.setContents(token(argument, '|', 0));
- p.setOptions(token(argument, '|', 1));
- } else {
- p.setContents(argument);
- }
- dispatch(FuncRequest(view(), LFUN_CITATION_INSERT, p.getAsString()));
- } else
- owner->getDialogs().createCitation(p.getAsString());
+ case LFUN_DIALOG_SHOW_NEXT_INSET: {
}
break;
+ case LFUN_DIALOG_UPDATE: {
+ string const & name = argument;
+ // Can only update a dialog connected to an existing inset
+ InsetBase * i = owner->getDialogs().getOpenInset(name);
+ if (!i)
+ break;
+
+ if (name == "bibitem" ||
+ name == "bibtex" ||
+ name == "citation" ||
+ name == "index" ||
+ name == "ref" ||
+ name == "toc" ||
+ name == "url") {
+ InsetCommand * inset = dynamic_cast<InsetCommand *>(i);
+ if (!inset)
+ break;
+
+ InsetCommandMailer mailer(name, *inset);
+ mailer.updateDialog();
+
+ } else if (name == "error") {
+ InsetError * inset = dynamic_cast<InsetError *>(i);
+ if (!inset)
+ break;
+
+ owner->getDialogs().update("error",
+ inset->getContents());
+
+ } else if (name == "ert") {
+ InsetERT * inset = dynamic_cast<InsetERT *>(i);
+ if (!inset)
+ break;
+
+ InsetERTMailer mailer(*inset);
+ mailer.updateDialog();
+ }
+ }
+ break;
+
+ case LFUN_DIALOG_HIDE:
+ owner ->getDialogs().hide(argument);
+ break;
+
+ case LFUN_DIALOG_DISCONNECT_INSET:
+ owner->getDialogs().disconnect(argument);
+ break;
+
case LFUN_CHILDOPEN:
{
string const filename =
+2003-02-21 Angus Leeming <leeming@lyx.org>
+
+ * formulabase.C (localDispatch): retire LFUN_REF_INSERT. Add
+ LFUN_DIALOG_SHOW_NEW_INSET "ref" and LFUN_REF_APPLY. The latter
+ is not yet safe. Posted some ideas to the list for further discussion.
+
+ * ref_inset.C (dispatch): a first stab at activating the code
+ to display the reference dialog from within mathed. Not yet working.
+
2003-02-14 Dekel Tsur <dekelts@tau.ac.il>
* math_parser.C (parse1): Do not remove braces for {<expr>}^
#include "textpainter.h"
#include "frontends/Dialogs.h"
#include "intl.h"
-#include "insets/insetcommandparams.h"
+#include "insets/insetcommand.h"
#include "ref_inset.h"
using std::endl;
updateLocal(bv, true);
break;
- case LFUN_REF_INSERT:
- //if (argument.empty()) {
- // InsetCommandParams p("ref");
- // owner_->getDialogs().createRef(p.getAsString());
- //} else {
- // InsetCommandParams p;
- // p.setFromString(argument);
-
- // InsetRef * inset = new InsetRef(p, *buffer_);
- // if (!insertInset(inset))
- // delete inset;
- // else
- // updateInset(inset, true);
- //}
- //
- if (cmd.argument.empty()) {
- InsetCommandParams p("ref");
- bv->owner()->getDialogs().createRef(p.getAsString());
+ case LFUN_DIALOG_SHOW_NEW_INSET: {
+ string const & name = argument;
+ if (name == "ref") {
+ InsetCommandParams p(name);
+ string data = InsetCommandMailer::params2string(p);
+ bv->owner()->getDialogs().show(name, data, 0);
+ } else
+ result = UNDISPATCHED;
+ }
+ break;
+
+ case LFUN_REF_APPLY: {
+ InsetCommandParams params;
+ InsetCommandMailer::string2params(argument, params);
+
+ // It would be nice if RefInset could handle an
+ // InsetCommandParams arg, but for now we convert it to
+ // 'foo|++|bar|++|nonsense'.
+ string const tmp = params.getAsString();
+
+ InsetBase * base =
+ bv->owner()->getDialogs().getOpenInset("ref");
+ if (base) {
+ RefInset * inset = dynamic_cast<RefInset *>(base);
+ if (!inset) {
+ result = UNDISPATCHED;
+ break;
+ }
+
+ *inset = RefInset(tmp);
} else {
- //mathcursor->handleNest(new InsetRef2);
- //mathcursor->insert(arg);
- mathcursor->insert(MathAtom(new RefInset(cmd.argument)));
+ mathcursor->insert(MathAtom(new RefInset(tmp)));
}
updateLocal(bv, true);
- break;
+ }
+ break;
default:
result = UNDISPATCHED;
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "debug.h"
+#include "math_mathmlstream.h"
+#include "Lsstream.h"
RefInset::RefInset()
dispatch_result
RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
+ lyxerr << "RefInset::dispatch" << std::endl;
+ lyxerr << "dispatching " << cmd.argument << "\n";
switch (cmd.action) {
- lyxerr << "dispatching " << cmd.argument << "\n";
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
lyxerr << "trying to goto ref" << cell(0) << "\n";
}
if (cmd.button() == mouse_button::button1) {
lyxerr << "trying to open ref" << cell(0) << "\n";
- // Eventually trigger dialog with button 3 not 1
- // cmd.view()->owner()->getDialogs()->showRef(this);
+ // Eventually trigger dialog with button 3
+ // not 1
+ ostringstream data;
+ WriteStream wsdata(data);
+ write(wsdata);
+
+ lyxerr << "ref_inset dispatch.\n"
+ << "this " << this << "\n"
+ << "The data is "<< data.str()
+ << std::endl;
+
+ cmd.view()->owner()->getDialogs().
+ show("ref", data.str(), this);
return DISPATCHED;
}
break;
case LFUN_HTMLURL: {
InsetCommandParams p("htmlurl");
- bv->owner()->getDialogs().createUrl(p.getAsString());
+ string const data = InsetCommandMailer::params2string(p);
+ bv->owner()->getDialogs().show("url", data, 0);
break;
}
case LFUN_URL: {
InsetCommandParams p("url");
- bv->owner()->getDialogs().createUrl(p.getAsString());
+ string const data = InsetCommandMailer::params2string(p);
+ bv->owner()->getDialogs().show("url", data, 0);
break;
}