mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
controller-view split for TOC popup.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1863 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a6adf5d732
commit
071d35750a
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
|
* lyxfunc.C (Dispatch): prevent crash in LFUN_GOTO_PARAGRAPH when
|
||||||
|
the LyXParagraph * is 0.
|
||||||
|
|
||||||
2001-03-29 Juergen Vigna <jug@sad.it>
|
2001-03-29 Juergen Vigna <jug@sad.it>
|
||||||
|
|
||||||
* vspace.C: added support for %, c%, p%, l%.
|
* vspace.C: added support for %, c%, p%, l%.
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
|
* ControlToc.[Ch]: new files; a controller for the TOC popup.
|
||||||
|
|
||||||
|
* GUI.h:
|
||||||
|
* Makefile.am: associated changes with all of the above.
|
||||||
|
|
||||||
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* ControlExternal.C: bug fixes. Can now apply changes to the inset
|
* ControlExternal.C: bug fixes. Can now apply changes to the inset
|
||||||
|
113
src/frontends/controllers/ControlToc.C
Normal file
113
src/frontends/controllers/ControlToc.C
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlToc.C
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlToc.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "Dialogs.h"
|
||||||
|
#include "LyXView.h"
|
||||||
|
#include "lyxfunc.h"
|
||||||
|
#include "support/lstrings.h" // tostr
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using SigC::slot;
|
||||||
|
|
||||||
|
ControlToc::ControlToc(LyXView & lv, Dialogs & d)
|
||||||
|
: ControlCommand(lv, d, LFUN_TOC_INSERT)
|
||||||
|
{
|
||||||
|
d_.showTOC.connect(slot(this, &ControlToc::showInset));
|
||||||
|
d_.createTOC.connect(slot(this, &ControlToc::createInset));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlToc::Goto(int const & id) const
|
||||||
|
{
|
||||||
|
string const tmp = tostr(id);
|
||||||
|
lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<string> const ControlToc::getTypes() const
|
||||||
|
{
|
||||||
|
vector<string> types;
|
||||||
|
|
||||||
|
Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
|
||||||
|
|
||||||
|
Buffer::Lists::const_iterator cit = tmp.begin();
|
||||||
|
Buffer::Lists::const_iterator end = tmp.end();
|
||||||
|
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
|
types.push_back(cit->first.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Buffer::SingleList const ControlToc::getContents(string const & type) const
|
||||||
|
{
|
||||||
|
Buffer::SingleList contents;
|
||||||
|
|
||||||
|
Buffer::TocItem noContent(0, 0, string());
|
||||||
|
|
||||||
|
// This shouldn't be possible...
|
||||||
|
if (!lv_.view()->available()) {
|
||||||
|
noContent.str = _("*** No Document ***");
|
||||||
|
contents.push_back(noContent);
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer::Lists tmp = lv_.view()->buffer()->getLists();
|
||||||
|
|
||||||
|
Buffer::Lists::iterator it = tmp.find(type);
|
||||||
|
|
||||||
|
if (it == tmp.end()) {
|
||||||
|
noContent.str = _("*** No Lists ***");
|
||||||
|
contents.push_back(noContent);
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace toc
|
||||||
|
{
|
||||||
|
|
||||||
|
string getType(string const & cmdName)
|
||||||
|
{
|
||||||
|
string type;
|
||||||
|
|
||||||
|
// It would be nice to have a map to extract this info.
|
||||||
|
// Does one already exist, Lars?
|
||||||
|
if (cmdName == "tableofcontents" )
|
||||||
|
type = "TOC";
|
||||||
|
|
||||||
|
else if (cmdName == "listofalgorithms" )
|
||||||
|
type = "algorithm";
|
||||||
|
|
||||||
|
else if (cmdName == "listoffigures" )
|
||||||
|
type = "figure";
|
||||||
|
|
||||||
|
else
|
||||||
|
type = "table";
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace toc
|
50
src/frontends/controllers/ControlToc.h
Normal file
50
src/frontends/controllers/ControlToc.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlToc.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTROLTOC_H
|
||||||
|
#define CONTROLTOC_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlCommand.h"
|
||||||
|
#include "buffer.h" // Buffer::SingleList
|
||||||
|
|
||||||
|
/** A controller for TOC dialogs.
|
||||||
|
*/
|
||||||
|
class ControlToc : public ControlCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
ControlToc(LyXView &, Dialogs &);
|
||||||
|
|
||||||
|
/// Goto this paragraph id
|
||||||
|
void Goto(int const & id) const;
|
||||||
|
|
||||||
|
/// Returns a vector of list types in the document
|
||||||
|
std::vector<string> const getTypes() const;
|
||||||
|
|
||||||
|
/// Given a type, returns the contents
|
||||||
|
Buffer::SingleList const getContents(string const & type) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace toc
|
||||||
|
{
|
||||||
|
/** Given the cmdName of the TOC param, returns the type used
|
||||||
|
by ControlToc::getContents() */
|
||||||
|
string getType(string const & cmdName);
|
||||||
|
|
||||||
|
} // namespace toc
|
||||||
|
|
||||||
|
#endif // CONTROLTOC_H
|
@ -294,6 +294,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Specialization for Toc dialog
|
||||||
|
*/
|
||||||
|
class ControlToc;
|
||||||
|
|
||||||
|
template <class GUIview, class GUIbc>
|
||||||
|
class GUIToc :
|
||||||
|
public GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc> {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
GUIToc(LyXView & lv, Dialogs & d)
|
||||||
|
: GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Specialization for TabularCreate dialog
|
/** Specialization for TabularCreate dialog
|
||||||
*/
|
*/
|
||||||
class ControlTabularCreate;
|
class ControlTabularCreate;
|
||||||
|
@ -65,6 +65,8 @@ libcontrollers_la_SOURCES=\
|
|||||||
ControlSplash.h \
|
ControlSplash.h \
|
||||||
ControlTabularCreate.C \
|
ControlTabularCreate.C \
|
||||||
ControlTabularCreate.h \
|
ControlTabularCreate.h \
|
||||||
|
ControlToc.C \
|
||||||
|
ControlToc.h \
|
||||||
ControlUrl.C \
|
ControlUrl.C \
|
||||||
ControlUrl.h \
|
ControlUrl.h \
|
||||||
ControlVCLog.C \
|
ControlVCLog.C \
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
|
* FormMathsPanel.C (c-tor): set button controller cancel label to close.
|
||||||
|
|
||||||
|
* FormToc.[Ch]:
|
||||||
|
* forms/form_toc.fd: implemented controller-view split.
|
||||||
|
|
||||||
|
* Dialogs.C: associated changes.
|
||||||
|
|
||||||
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* FormCitation.C:
|
* FormCitation.C:
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "ControlSearch.h"
|
#include "ControlSearch.h"
|
||||||
#include "ControlSplash.h"
|
#include "ControlSplash.h"
|
||||||
#include "ControlTabularCreate.h"
|
#include "ControlTabularCreate.h"
|
||||||
|
#include "ControlToc.h"
|
||||||
#include "ControlUrl.h"
|
#include "ControlUrl.h"
|
||||||
#include "ControlVCLog.h"
|
#include "ControlVCLog.h"
|
||||||
|
|
||||||
@ -63,6 +64,7 @@
|
|||||||
#include "form_search.h"
|
#include "form_search.h"
|
||||||
#include "form_splash.h"
|
#include "form_splash.h"
|
||||||
#include "form_tabular_create.h"
|
#include "form_tabular_create.h"
|
||||||
|
#include "form_toc.h"
|
||||||
#include "form_url.h"
|
#include "form_url.h"
|
||||||
|
|
||||||
#include "FormBibitem.h"
|
#include "FormBibitem.h"
|
||||||
@ -84,6 +86,7 @@
|
|||||||
#include "FormSearch.h"
|
#include "FormSearch.h"
|
||||||
#include "FormSplash.h"
|
#include "FormSplash.h"
|
||||||
#include "FormTabularCreate.h"
|
#include "FormTabularCreate.h"
|
||||||
|
#include "FormToc.h"
|
||||||
#include "FormUrl.h"
|
#include "FormUrl.h"
|
||||||
#include "FormVCLog.h"
|
#include "FormVCLog.h"
|
||||||
|
|
||||||
@ -92,7 +95,6 @@
|
|||||||
#include "FormParagraph.h"
|
#include "FormParagraph.h"
|
||||||
#include "FormPreferences.h"
|
#include "FormPreferences.h"
|
||||||
#include "FormTabular.h"
|
#include "FormTabular.h"
|
||||||
#include "FormToc.h"
|
|
||||||
|
|
||||||
// Signal enabling all visible popups to be redrawn if so desired.
|
// Signal enabling all visible popups to be redrawn if so desired.
|
||||||
// E.g., when the GUI colours have been remapped.
|
// E.g., when the GUI colours have been remapped.
|
||||||
@ -120,6 +122,7 @@ Dialogs::Dialogs(LyXView * lv)
|
|||||||
add(new GUIRef<FormRef, xformsBC>(*lv, *this));
|
add(new GUIRef<FormRef, xformsBC>(*lv, *this));
|
||||||
add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
|
add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
|
||||||
add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
|
add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
|
||||||
|
add(new GUIToc<FormToc, xformsBC>(*lv, *this));
|
||||||
add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
|
add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
|
||||||
add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
|
add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
|
||||||
|
|
||||||
@ -128,7 +131,6 @@ Dialogs::Dialogs(LyXView * lv)
|
|||||||
add(new FormParagraph(lv, this));
|
add(new FormParagraph(lv, this));
|
||||||
add(new FormPreferences(lv, this));
|
add(new FormPreferences(lv, this));
|
||||||
add(new FormTabular(lv, this));
|
add(new FormTabular(lv, this));
|
||||||
add(new FormToc(lv, this));
|
|
||||||
|
|
||||||
// reduce the number of connections needed in
|
// reduce the number of connections needed in
|
||||||
// dialogs by a simple connection here.
|
// dialogs by a simple connection here.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000-2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/* This file is part of
|
/* This file is part of
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000-2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
|
* \file FormCitation.h
|
||||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ using SigC::slot;
|
|||||||
|
|
||||||
FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d)
|
FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d)
|
||||||
: FormBaseBD(lv, d, _("Maths Panel")),
|
: FormBaseBD(lv, d, _("Maths Panel")),
|
||||||
active_(0)
|
active_(0), bc_("Close")
|
||||||
{
|
{
|
||||||
deco_.reset( new FormMathsDeco( lv, d, *this));
|
deco_.reset( new FormMathsDeco( lv, d, *this));
|
||||||
delim_.reset( new FormMathsDelim( lv, d, *this));
|
delim_.reset( new FormMathsDelim( lv, d, *this));
|
||||||
@ -263,7 +263,7 @@ void FormMathsPanel::mathDisplay() const
|
|||||||
|
|
||||||
FormMathsSub::FormMathsSub(LyXView * lv, Dialogs * d, FormMathsPanel const & p,
|
FormMathsSub::FormMathsSub(LyXView * lv, Dialogs * d, FormMathsPanel const & p,
|
||||||
string const & t)
|
string const & t)
|
||||||
: FormBaseBD(lv, d, t), parent_(p)
|
: FormBaseBD(lv, d, t), parent_(p), bc_("Close")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,81 +1,45 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/* This file is part of
|
/* This file is part of
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000-2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file FormToc.C
|
||||||
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include FORMS_H_LOCATION
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xformsBC.h"
|
||||||
#include "Dialogs.h"
|
#include "ControlToc.h"
|
||||||
#include "FormToc.h"
|
#include "FormToc.h"
|
||||||
#include "LyXView.h"
|
|
||||||
#include "form_toc.h"
|
#include "form_toc.h"
|
||||||
#include "lyxtext.h"
|
#include "helper_funcs.h" // getStringFromVector
|
||||||
#include "lyxfunc.h"
|
#include "support/lstrings.h" // frontStrip, strip
|
||||||
#include "support/lstrings.h"
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using SigC::slot;
|
|
||||||
|
|
||||||
// The current code uses the apply() for handling the Update button and the
|
|
||||||
// type-of-table selection and cancel() for the close button. This is a little
|
|
||||||
// confusing to the button controller so I've made an IgnorantPolicy to cover
|
|
||||||
// this situation since the dialog doesn't care about buttons. ARRae 20001013
|
|
||||||
FormToc::FormToc(LyXView * lv, Dialogs * d)
|
|
||||||
: FormCommand(lv, d, _("Table of Contents")),
|
|
||||||
dialog_(0)
|
|
||||||
{
|
|
||||||
// let the dialog be shown
|
|
||||||
// These are permanent connections so we won't bother
|
|
||||||
// storing a copy because we won't be disconnecting.
|
|
||||||
d->showTOC.connect(slot(this, &FormToc::showInset));
|
|
||||||
d->createTOC.connect(slot(this, &FormToc::createInset));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FL_FORM * FormToc::form() const
|
typedef FormCB<ControlToc, FormDB<FD_form_toc> > base_class;
|
||||||
{
|
|
||||||
if (dialog_.get())
|
|
||||||
return dialog_->form;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FormToc::FormToc(ControlToc & c)
|
||||||
void FormToc::disconnect()
|
: base_class(c, _("Table of Contents"))
|
||||||
{
|
{}
|
||||||
toclist.clear();
|
|
||||||
FormCommand::disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FormToc::build()
|
void FormToc::build()
|
||||||
{
|
{
|
||||||
dialog_.reset(build_toc());
|
dialog_.reset(build_toc());
|
||||||
|
|
||||||
#if 0
|
string const choice =
|
||||||
fl_addto_choice(dialog_->choice_toc_type,
|
" " + getStringFromVector(controller().getTypes(), " | ") + " ";
|
||||||
_(" TOC | LOF | LOT | LOA "));
|
fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
|
||||||
#else
|
|
||||||
Buffer::Lists const tmp = lv_->view()->buffer()->getLists();
|
|
||||||
Buffer::Lists::const_iterator cit = tmp.begin();
|
|
||||||
Buffer::Lists::const_iterator end = tmp.end();
|
|
||||||
for (; cit != end; ++cit) {
|
|
||||||
fl_addto_choice(dialog_->choice_toc_type, cit->first.c_str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Manage the cancel/close button
|
// Manage the cancel/close button
|
||||||
bc().setCancel(dialog_->button_cancel);
|
bc().setCancel(dialog_->button_cancel);
|
||||||
@ -85,122 +49,65 @@ void FormToc::build()
|
|||||||
|
|
||||||
void FormToc::update()
|
void FormToc::update()
|
||||||
{
|
{
|
||||||
#if 0
|
updateType();
|
||||||
Buffer::TocType type;
|
updateContents();
|
||||||
|
|
||||||
if (params.getCmdName() == "tableofcontents" )
|
|
||||||
type = Buffer::TOC_TOC;
|
|
||||||
|
|
||||||
else if (params.getCmdName() == "listofalgorithms" )
|
|
||||||
type = Buffer::TOC_LOA;
|
|
||||||
|
|
||||||
else if (params.getCmdName() == "listoffigures" )
|
|
||||||
type = Buffer::TOC_LOF;
|
|
||||||
|
|
||||||
else
|
|
||||||
type = Buffer::TOC_LOT;
|
|
||||||
|
|
||||||
fl_set_choice( dialog_->choice_toc_type, type+1 );
|
|
||||||
#else
|
|
||||||
#warning Reimplement (Lgb)
|
|
||||||
#endif
|
|
||||||
updateToc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FormToc::updateToc()
|
ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long)
|
||||||
{
|
{
|
||||||
#if 0
|
updateContents();
|
||||||
if (!lv_->view()->available()) {
|
|
||||||
toclist.clear();
|
unsigned int const choice = fl_get_browser( dialog_->browser_toc );
|
||||||
fl_clear_browser( dialog_->browser_toc );
|
if (0 < choice && choice - 1 < toclist_.size()) {
|
||||||
fl_add_browser_line( dialog_->browser_toc,
|
controller().Goto(toclist_[choice-1].par->id());
|
||||||
_("*** No Document ***"));
|
}
|
||||||
|
|
||||||
|
return ButtonPolicy::SMI_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormToc::updateType()
|
||||||
|
{
|
||||||
|
string const type = toc::getType(controller().params().getCmdName());
|
||||||
|
|
||||||
|
fl_set_choice(dialog_->choice_toc_type, 1);
|
||||||
|
for (int i = 1;
|
||||||
|
i <= fl_get_choice_maxitems(dialog_->choice_toc_type); ++i) {
|
||||||
|
string const choice =
|
||||||
|
fl_get_choice_item_text(dialog_->choice_toc_type, i);
|
||||||
|
|
||||||
|
if (choice == type) {
|
||||||
|
fl_set_choice(dialog_->choice_toc_type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormToc::updateContents()
|
||||||
|
{
|
||||||
|
string const type =
|
||||||
|
frontStrip(strip(fl_get_choice_text(dialog_->choice_toc_type)));
|
||||||
|
|
||||||
|
Buffer::SingleList const contents = controller().getContents(type);
|
||||||
|
|
||||||
|
// Check if all elements are the same.
|
||||||
|
if (toclist_ == contents) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<vector<Buffer::TocItem> > tmp =
|
|
||||||
lv_->view()->buffer()->getTocList();
|
|
||||||
int type = fl_get_choice( dialog_->choice_toc_type ) - 1;
|
|
||||||
|
|
||||||
// Check if all elements are the same.
|
|
||||||
if (toclist.size() == tmp[type].size()) {
|
|
||||||
unsigned int i = 0;
|
|
||||||
for (; i < toclist.size(); ++i) {
|
|
||||||
if (toclist[i] != tmp[type][i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= toclist.size()) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// List has changed. Update browser
|
// List has changed. Update browser
|
||||||
toclist = tmp[type];
|
toclist_ = contents;
|
||||||
|
|
||||||
static Buffer * buffer = 0;
|
unsigned int const topline =
|
||||||
int topline = 0;
|
fl_get_browser_topline(dialog_->browser_toc);
|
||||||
int line = 0;
|
unsigned int const line = fl_get_browser(dialog_->browser_toc);
|
||||||
if (buffer == lv_->view()->buffer()) {
|
|
||||||
topline = fl_get_browser_topline( dialog_->browser_toc );
|
|
||||||
line = fl_get_browser( dialog_->browser_toc );
|
|
||||||
} else
|
|
||||||
buffer = lv_->view()->buffer();
|
|
||||||
|
|
||||||
fl_clear_browser( dialog_->browser_toc );
|
fl_clear_browser( dialog_->browser_toc );
|
||||||
|
|
||||||
for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
|
Buffer::SingleList::const_iterator cit = toclist_.begin();
|
||||||
it != toclist.end(); ++it)
|
Buffer::SingleList::const_iterator end = toclist_.end();
|
||||||
fl_add_browser_line( dialog_->browser_toc,
|
|
||||||
(string(4 * (*it).depth, ' ')
|
|
||||||
+ (*it).str).c_str());
|
|
||||||
|
|
||||||
fl_set_browser_topline( dialog_->browser_toc, topline );
|
|
||||||
fl_select_browser_line( dialog_->browser_toc, line );
|
|
||||||
#else
|
|
||||||
#warning Fix Me! (Lgb)
|
|
||||||
if (!lv_->view()->available()) {
|
|
||||||
toclist.clear();
|
|
||||||
fl_clear_browser( dialog_->browser_toc );
|
|
||||||
fl_add_browser_line( dialog_->browser_toc,
|
|
||||||
_("*** No Document ***"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Buffer::Lists tmp = lv_->view()->buffer()->getLists();
|
|
||||||
string const type =
|
|
||||||
fl_get_choice_item_text(dialog_->choice_toc_type,
|
|
||||||
fl_get_choice(dialog_->choice_toc_type));
|
|
||||||
|
|
||||||
Buffer::Lists::iterator it = tmp.find(type);
|
|
||||||
|
|
||||||
if (it != tmp.end()) {
|
|
||||||
// Check if all elements are the same.
|
|
||||||
if (toclist == it->second) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (it == tmp.end()) {
|
|
||||||
toclist.clear();
|
|
||||||
fl_clear_browser(dialog_->browser_toc);
|
|
||||||
fl_add_browser_line(dialog_->browser_toc,
|
|
||||||
_("*** No Lists ***"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// List has changed. Update browser
|
|
||||||
toclist = it->second;
|
|
||||||
|
|
||||||
static Buffer * buffer = 0;
|
|
||||||
int topline = 0;
|
|
||||||
int line = 0;
|
|
||||||
if (buffer == lv_->view()->buffer()) {
|
|
||||||
topline = fl_get_browser_topline(dialog_->browser_toc);
|
|
||||||
line = fl_get_browser( dialog_->browser_toc );
|
|
||||||
} else
|
|
||||||
buffer = lv_->view()->buffer();
|
|
||||||
|
|
||||||
fl_clear_browser(dialog_->browser_toc);
|
|
||||||
|
|
||||||
Buffer::SingleList::const_iterator cit = toclist.begin();
|
|
||||||
Buffer::SingleList::const_iterator end = toclist.end();
|
|
||||||
|
|
||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit) {
|
||||||
string const line = string(4 * cit->depth, ' ') + cit->str;
|
string const line = string(4 * cit->depth, ' ') + cit->str;
|
||||||
@ -209,19 +116,4 @@ void FormToc::updateToc()
|
|||||||
|
|
||||||
fl_set_browser_topline(dialog_->browser_toc, topline);
|
fl_set_browser_topline(dialog_->browser_toc, topline);
|
||||||
fl_select_browser_line(dialog_->browser_toc, line);
|
fl_select_browser_line(dialog_->browser_toc, line);
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool FormToc::input(FL_OBJECT *, long)
|
|
||||||
{
|
|
||||||
updateToc();
|
|
||||||
|
|
||||||
unsigned int const choice = fl_get_browser( dialog_->browser_toc );
|
|
||||||
if (0 < choice && choice - 1 < toclist.size()) {
|
|
||||||
string const tmp = tostr(toclist[choice-1].par->id());
|
|
||||||
lv_->getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
@ -1,67 +1,56 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/* This file is part of
|
/* This file is part of
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000-2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file FormToc.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FORMTOC_H
|
#ifndef FORMTOC_H
|
||||||
#define FORMTOC_H
|
#define FORMTOC_H
|
||||||
|
|
||||||
#include <boost/smart_ptr.hpp>
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "FormInset.h"
|
#include "FormBase.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
|
||||||
|
class ControlToc;
|
||||||
struct FD_form_toc;
|
struct FD_form_toc;
|
||||||
|
|
||||||
/** This class provides an XForms implementation of the FormToc Dialog.
|
/** This class provides an XForms implementation of the FormToc Dialog.
|
||||||
*/
|
*/
|
||||||
class FormToc : public FormCommand {
|
class FormToc : public FormCB<ControlToc, FormDB<FD_form_toc> > {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormToc(LyXView *, Dialogs *);
|
FormToc(ControlToc &);
|
||||||
private:
|
|
||||||
/// Pointer to the actual instantiation of the ButtonController.
|
|
||||||
virtual xformsBC & bc();
|
|
||||||
/// Disconnect signals. Also perform any necessary housekeeping.
|
|
||||||
virtual void disconnect();
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// not needed
|
||||||
|
virtual void apply() {}
|
||||||
/// Build the dialog
|
/// Build the dialog
|
||||||
virtual void build();
|
virtual void build();
|
||||||
/// bool indicates if a buffer switch took place
|
|
||||||
virtual void updateSlot(bool) { update(); }
|
|
||||||
/// Update dialog before showing it
|
/// Update dialog before showing it
|
||||||
virtual void update();
|
virtual void update();
|
||||||
/// Filter the inputs on callback from xforms
|
/// Filter the inputs on callback from xforms
|
||||||
virtual bool input( FL_OBJECT *, long);
|
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||||
/// Pointer to the actual instantiation of the xforms form
|
|
||||||
virtual FL_FORM * form() const;
|
|
||||||
///
|
///
|
||||||
void updateToc();
|
void updateType();
|
||||||
///
|
///
|
||||||
|
void updateContents();
|
||||||
|
|
||||||
|
/// Fdesign generated method
|
||||||
FD_form_toc * build_toc();
|
FD_form_toc * build_toc();
|
||||||
|
|
||||||
///
|
///
|
||||||
Buffer::SingleList toclist;
|
Buffer::SingleList toclist_;
|
||||||
/// Real GUI implementation.
|
|
||||||
boost::scoped_ptr<FD_form_toc> dialog_;
|
|
||||||
/// The ButtonController
|
|
||||||
ButtonController<OkCancelPolicy, xformsBC> bc_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // FORMTOC_H
|
||||||
inline
|
|
||||||
xformsBC & FormToc::bc()
|
|
||||||
{
|
|
||||||
return bc_;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -27,7 +27,7 @@ FD_form_toc * FormToc::build_toc()
|
|||||||
obj = fl_add_box(FL_UP_BOX, 0, 0, 420, 340, "");
|
obj = fl_add_box(FL_UP_BOX, 0, 0, 420, 340, "");
|
||||||
fdui->browser_toc = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 10, 400, 280, "");
|
fdui->browser_toc = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 10, 400, 280, "");
|
||||||
fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
|
fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
|
||||||
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
|
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||||
{
|
{
|
||||||
char const * const dummy = N_("Update|#U");
|
char const * const dummy = N_("Update|#U");
|
||||||
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 300, 100, 30, idex(_(dummy)));
|
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 300, 100, 30, idex(_(dummy)));
|
||||||
@ -35,7 +35,7 @@ FD_form_toc * FormToc::build_toc()
|
|||||||
}
|
}
|
||||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||||
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
|
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||||
{
|
{
|
||||||
char const * const dummy = N_("Type|#T");
|
char const * const dummy = N_("Type|#T");
|
||||||
fdui->choice_toc_type = obj = fl_add_choice(FL_NORMAL_CHOICE, 60, 300, 130, 30, idex(_(dummy)));
|
fdui->choice_toc_type = obj = fl_add_choice(FL_NORMAL_CHOICE, 60, 300, 130, 30, idex(_(dummy)));
|
||||||
@ -43,7 +43,7 @@ FD_form_toc * FormToc::build_toc()
|
|||||||
}
|
}
|
||||||
fl_set_object_boxtype(obj, FL_FRAME_BOX);
|
fl_set_object_boxtype(obj, FL_FRAME_BOX);
|
||||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||||
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
|
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||||
{
|
{
|
||||||
char const * const dummy = N_("Close|^[^M");
|
char const * const dummy = N_("Close|^[^M");
|
||||||
fdui->button_cancel = obj = fl_add_button(FL_RETURN_BUTTON, 310, 300, 100, 30, idex(_(dummy)));
|
fdui->button_cancel = obj = fl_add_button(FL_RETURN_BUTTON, 310, 300, 100, 30, idex(_(dummy)));
|
||||||
@ -51,7 +51,7 @@ FD_form_toc * FormToc::build_toc()
|
|||||||
}
|
}
|
||||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||||
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
|
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
|
||||||
fl_end_form();
|
fl_end_form();
|
||||||
|
|
||||||
fdui->form->fdui = fdui;
|
fdui->form->fdui = fdui;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#define FD_form_toc_h_
|
#define FD_form_toc_h_
|
||||||
|
|
||||||
/** Callbacks, globals and object handlers **/
|
/** Callbacks, globals and object handlers **/
|
||||||
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
|
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
|
||||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||||
|
|
||||||
|
|
||||||
/**** Forms and Objects ****/
|
/**** Forms and Objects ****/
|
||||||
|
@ -45,7 +45,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_ALL
|
resize: FL_RESIZE_ALL
|
||||||
gravity: FL_NorthWest FL_SouthEast
|
gravity: FL_NorthWest FL_SouthEast
|
||||||
name: browser_toc
|
name: browser_toc
|
||||||
callback: C_FormBaseDeprecatedInputCB
|
callback: C_FormBaseInputCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
@ -63,7 +63,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_NONE
|
resize: FL_RESIZE_NONE
|
||||||
gravity: FL_SouthEast FL_SouthEast
|
gravity: FL_SouthEast FL_SouthEast
|
||||||
name: button_update
|
name: button_update
|
||||||
callback: C_FormBaseDeprecatedInputCB
|
callback: C_FormBaseInputCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
@ -81,7 +81,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_NONE
|
resize: FL_RESIZE_NONE
|
||||||
gravity: FL_SouthEast FL_SouthEast
|
gravity: FL_SouthEast FL_SouthEast
|
||||||
name: choice_toc_type
|
name: choice_toc_type
|
||||||
callback: C_FormBaseDeprecatedInputCB
|
callback: C_FormBaseInputCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
@ -99,7 +99,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_NONE
|
resize: FL_RESIZE_NONE
|
||||||
gravity: FL_SouthEast FL_SouthEast
|
gravity: FL_SouthEast FL_SouthEast
|
||||||
name: button_cancel
|
name: button_cancel
|
||||||
callback: C_FormBaseDeprecatedCancelCB
|
callback: C_FormBaseCancelCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
==============================
|
==============================
|
||||||
|
@ -1227,6 +1227,8 @@ string const LyXFunc::Dispatch(int ac,
|
|||||||
int id;
|
int id;
|
||||||
istr >> id;
|
istr >> id;
|
||||||
LyXParagraph * par = TEXT()->GetParFromID(id);
|
LyXParagraph * par = TEXT()->GetParFromID(id);
|
||||||
|
if (par == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
// Set the cursor
|
// Set the cursor
|
||||||
TEXT()->SetCursor(owner->view(), par, 0);
|
TEXT()->SetCursor(owner->view(), par, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user