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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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
|
||||
*/
|
||||
class ControlTabularCreate;
|
||||
|
@ -65,6 +65,8 @@ libcontrollers_la_SOURCES=\
|
||||
ControlSplash.h \
|
||||
ControlTabularCreate.C \
|
||||
ControlTabularCreate.h \
|
||||
ControlToc.C \
|
||||
ControlToc.h \
|
||||
ControlUrl.C \
|
||||
ControlUrl.h \
|
||||
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>
|
||||
|
||||
* FormCitation.C:
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "ControlSearch.h"
|
||||
#include "ControlSplash.h"
|
||||
#include "ControlTabularCreate.h"
|
||||
#include "ControlToc.h"
|
||||
#include "ControlUrl.h"
|
||||
#include "ControlVCLog.h"
|
||||
|
||||
@ -63,6 +64,7 @@
|
||||
#include "form_search.h"
|
||||
#include "form_splash.h"
|
||||
#include "form_tabular_create.h"
|
||||
#include "form_toc.h"
|
||||
#include "form_url.h"
|
||||
|
||||
#include "FormBibitem.h"
|
||||
@ -84,6 +86,7 @@
|
||||
#include "FormSearch.h"
|
||||
#include "FormSplash.h"
|
||||
#include "FormTabularCreate.h"
|
||||
#include "FormToc.h"
|
||||
#include "FormUrl.h"
|
||||
#include "FormVCLog.h"
|
||||
|
||||
@ -92,7 +95,6 @@
|
||||
#include "FormParagraph.h"
|
||||
#include "FormPreferences.h"
|
||||
#include "FormTabular.h"
|
||||
#include "FormToc.h"
|
||||
|
||||
// Signal enabling all visible popups to be redrawn if so desired.
|
||||
// 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 GUISearch<FormSearch, 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 GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
|
||||
|
||||
@ -128,7 +131,6 @@ Dialogs::Dialogs(LyXView * lv)
|
||||
add(new FormParagraph(lv, this));
|
||||
add(new FormPreferences(lv, this));
|
||||
add(new FormTabular(lv, this));
|
||||
add(new FormToc(lv, this));
|
||||
|
||||
// reduce the number of connections needed in
|
||||
// dialogs by a simple connection here.
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* 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
|
||||
* ======================================================
|
||||
*
|
||||
* 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>
|
||||
*/
|
||||
|
||||
|
@ -55,7 +55,7 @@ using SigC::slot;
|
||||
|
||||
FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d)
|
||||
: FormBaseBD(lv, d, _("Maths Panel")),
|
||||
active_(0)
|
||||
active_(0), bc_("Close")
|
||||
{
|
||||
deco_.reset( new FormMathsDeco( 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,
|
||||
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
|
||||
* ======================================================
|
||||
*
|
||||
* 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 <vector>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
|
||||
#include "Dialogs.h"
|
||||
#include "xformsBC.h"
|
||||
#include "ControlToc.h"
|
||||
#include "FormToc.h"
|
||||
#include "LyXView.h"
|
||||
#include "form_toc.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxfunc.h"
|
||||
#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));
|
||||
}
|
||||
#include "helper_funcs.h" // getStringFromVector
|
||||
#include "support/lstrings.h" // frontStrip, strip
|
||||
|
||||
|
||||
FL_FORM * FormToc::form() const
|
||||
{
|
||||
if (dialog_.get())
|
||||
return dialog_->form;
|
||||
return 0;
|
||||
}
|
||||
typedef FormCB<ControlToc, FormDB<FD_form_toc> > base_class;
|
||||
|
||||
|
||||
void FormToc::disconnect()
|
||||
{
|
||||
toclist.clear();
|
||||
FormCommand::disconnect();
|
||||
}
|
||||
FormToc::FormToc(ControlToc & c)
|
||||
: base_class(c, _("Table of Contents"))
|
||||
{}
|
||||
|
||||
|
||||
void FormToc::build()
|
||||
{
|
||||
dialog_.reset(build_toc());
|
||||
|
||||
#if 0
|
||||
fl_addto_choice(dialog_->choice_toc_type,
|
||||
_(" TOC | LOF | LOT | LOA "));
|
||||
#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
|
||||
string const choice =
|
||||
" " + getStringFromVector(controller().getTypes(), " | ") + " ";
|
||||
fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
|
||||
|
||||
// Manage the cancel/close button
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
@ -85,122 +49,65 @@ void FormToc::build()
|
||||
|
||||
void FormToc::update()
|
||||
{
|
||||
#if 0
|
||||
Buffer::TocType type;
|
||||
|
||||
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();
|
||||
updateType();
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
||||
void FormToc::updateToc()
|
||||
ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long)
|
||||
{
|
||||
#if 0
|
||||
if (!lv_->view()->available()) {
|
||||
toclist.clear();
|
||||
fl_clear_browser( dialog_->browser_toc );
|
||||
fl_add_browser_line( dialog_->browser_toc,
|
||||
_("*** No Document ***"));
|
||||
return;
|
||||
updateContents();
|
||||
|
||||
unsigned int const choice = fl_get_browser( dialog_->browser_toc );
|
||||
if (0 < choice && choice - 1 < toclist_.size()) {
|
||||
controller().Goto(toclist_[choice-1].par->id());
|
||||
}
|
||||
|
||||
vector<vector<Buffer::TocItem> > tmp =
|
||||
lv_->view()->buffer()->getTocList();
|
||||
int type = fl_get_choice( dialog_->choice_toc_type ) - 1;
|
||||
return ButtonPolicy::SMI_VALID;
|
||||
}
|
||||
|
||||
// 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])
|
||||
|
||||
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;
|
||||
}
|
||||
if (i >= toclist.size()) return;
|
||||
}
|
||||
}
|
||||
|
||||
// List has changed. Update browser
|
||||
toclist = tmp[type];
|
||||
|
||||
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 );
|
||||
|
||||
for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
|
||||
it != toclist.end(); ++it)
|
||||
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();
|
||||
void FormToc::updateContents()
|
||||
{
|
||||
string const type =
|
||||
fl_get_choice_item_text(dialog_->choice_toc_type,
|
||||
fl_get_choice(dialog_->choice_toc_type));
|
||||
frontStrip(strip(fl_get_choice_text(dialog_->choice_toc_type)));
|
||||
|
||||
Buffer::Lists::iterator it = tmp.find(type);
|
||||
Buffer::SingleList const contents = controller().getContents(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 ***"));
|
||||
if (toclist_ == contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
// List has changed. Update browser
|
||||
toclist = it->second;
|
||||
toclist_ = contents;
|
||||
|
||||
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();
|
||||
unsigned int const topline =
|
||||
fl_get_browser_topline(dialog_->browser_toc);
|
||||
unsigned int const line = fl_get_browser(dialog_->browser_toc);
|
||||
|
||||
fl_clear_browser(dialog_->browser_toc);
|
||||
fl_clear_browser( dialog_->browser_toc );
|
||||
|
||||
Buffer::SingleList::const_iterator cit = toclist.begin();
|
||||
Buffer::SingleList::const_iterator end = toclist.end();
|
||||
Buffer::SingleList::const_iterator cit = toclist_.begin();
|
||||
Buffer::SingleList::const_iterator end = toclist_.end();
|
||||
|
||||
for (; cit != end; ++cit) {
|
||||
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_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
|
||||
* ======================================================
|
||||
*
|
||||
* 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
|
||||
#define FORMTOC_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormInset.h"
|
||||
#include "FormBase.h"
|
||||
#include "buffer.h"
|
||||
|
||||
class ControlToc;
|
||||
struct FD_form_toc;
|
||||
|
||||
/** This class provides an XForms implementation of the FormToc Dialog.
|
||||
*/
|
||||
class FormToc : public FormCommand {
|
||||
class FormToc : public FormCB<ControlToc, FormDB<FD_form_toc> > {
|
||||
public:
|
||||
///
|
||||
FormToc(LyXView *, Dialogs *);
|
||||
private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
virtual xformsBC & bc();
|
||||
/// Disconnect signals. Also perform any necessary housekeeping.
|
||||
virtual void disconnect();
|
||||
FormToc(ControlToc &);
|
||||
|
||||
private:
|
||||
/// not needed
|
||||
virtual void apply() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// bool indicates if a buffer switch took place
|
||||
virtual void updateSlot(bool) { update(); }
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual bool input( FL_OBJECT *, long);
|
||||
/// Pointer to the actual instantiation of the xforms form
|
||||
virtual FL_FORM * form() const;
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
///
|
||||
void updateToc();
|
||||
void updateType();
|
||||
///
|
||||
void updateContents();
|
||||
|
||||
/// Fdesign generated method
|
||||
FD_form_toc * build_toc();
|
||||
|
||||
///
|
||||
Buffer::SingleList toclist;
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_form_toc> dialog_;
|
||||
/// The ButtonController
|
||||
ButtonController<OkCancelPolicy, xformsBC> bc_;
|
||||
Buffer::SingleList toclist_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
xformsBC & FormToc::bc()
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
#endif
|
||||
#endif // FORMTOC_H
|
||||
|
@ -27,7 +27,7 @@ FD_form_toc * FormToc::build_toc()
|
||||
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, "");
|
||||
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");
|
||||
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_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");
|
||||
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_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");
|
||||
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_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();
|
||||
|
||||
fdui->form->fdui = fdui;
|
||||
|
@ -5,8 +5,8 @@
|
||||
#define FD_form_toc_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
|
@ -45,7 +45,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NorthWest FL_SouthEast
|
||||
name: browser_toc
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -63,7 +63,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: button_update
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -81,7 +81,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: choice_toc_type
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -99,7 +99,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: button_cancel
|
||||
callback: C_FormBaseDeprecatedCancelCB
|
||||
callback: C_FormBaseCancelCB
|
||||
argument: 0
|
||||
|
||||
==============================
|
||||
|
@ -1227,6 +1227,8 @@ string const LyXFunc::Dispatch(int ac,
|
||||
int id;
|
||||
istr >> id;
|
||||
LyXParagraph * par = TEXT()->GetParFromID(id);
|
||||
if (par == 0)
|
||||
break;
|
||||
|
||||
// Set the cursor
|
||||
TEXT()->SetCursor(owner->view(), par, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user