patch from Angus and patch from Kayvan

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@930 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-07-27 08:55:59 +00:00
parent bc6d7e361b
commit 338bca184c
28 changed files with 618 additions and 576 deletions

View File

@ -1,3 +1,45 @@
2000-07-26 Kayvan A. Sylvan <kayvan@sylvan.com>
* development/lyx.spec.in
* Makefile.am: Fix buglet for LyX RPM generation resulting from
file/directory re-organization.
2000-07-26 Angus Leeming <a.leeming@ic.ac.uk>
* src/insets/insetcommand.[Ch]: moved the string data and
associated manipulation methods into a new stand-alone class
InsetCommandParams. This class has two additional methods
getAsString() and setFromString() allowing the contents to be
moved around as a single string.
(addContents) method removed.
(setContents) method no longer virtual.
* src/buffer.C (readInset): made use of new InsetCitation,
InsetUrl constructors based on InsetCommandParams.
* src/commandtags.h: add LFUN_INSERT_URL
* src/lyxfunc.C (Dispatch): changed to accomadate GUI-
independent InsetUrl and use InsetCommandParams to extract
string info and create new Insets.
* src/frontends/Dialogs.h: add signals showUrl, createUrl.
* src/frontends/xforms/FormCitation.C (apply): uses
InsetCommandParams.
* src/frontends/xforms/form_url.C
* src/frontends/xforms/form_url.h
* src/frontends/xforms/FormUrl.h
* src/frontends/xforms/FormUrl.C
* src/frontends/xforms/forms/form_url.fd: new files
* src/insets/insetcite.[Ch]: removed unused constructors.
* src/insets/insetinclude.[Ch]: no longer store filename
* src/insets/inseturl.[Ch]: GUI-independent.
2000-07-26 Juergen Vigna <jug@sad.it>
* renamed frontend from gtk to gnome as it is that what is realized
and did the necessary changes in the files.

View File

@ -25,7 +25,7 @@ dist-hook:
rm -rf `find images -name \*CVS\*`
rpmdist: dist
ln -s images/lyx.xpm . ; \
ln -s lib/images/lyx.xpm . ; \
rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \
rm lyx.xpm

View File

@ -38,8 +38,17 @@ place that the Redhat tetex package is installed and would see it.
%build
unset LINGUAS || true
CXXFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" \
./configure --prefix=/usr --without-warnings
make
./configure --prefix=/usr --without-warnings --with-included-string
# The following check is to ensure that lyx RPMs generated on RH 6.X machines
# with gcc-2.95 still run against older Redhat OS/compiler combinations.
# It will eventually be ripped out.
if [ -r /usr/lib/libstdc++-libc6.1-1.so.2 ]
then
make CXX=gcc LYX_LIBS='/usr/lib/libstdc++-libc6.1-1.so.2 -lforms -lXpm'
else
make
fi
%install
unset LINGUAS || true
@ -59,7 +68,7 @@ cp -r ${RPM_BUILD_ROOT}/usr/share/lyx/tex \
#
# Miscellaneous files
#
cp -a images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/
cp -a lib/images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/
cp lib/reLyX/README README.reLyX
%clean

View File

@ -1,250 +0,0 @@
Magic: 13000
Internal Form Definition File
(do not change)
Number of forms: 1
Unit of measure: FL_COORD_PIXEL
=============== FORM ===============
Name: citation_form
Width: 440
Height: 790
Number of Objects: 13
--------------------
class: FL_BOX
type: UP_BOX
box: 0 0 440 790
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: box
callback:
argument:
--------------------
class: FL_BROWSER
type: HOLD_BROWSER
box: 20 40 170 370
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Inset keys
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: citeBrsr
callback: citation_cb
argument: InsetCitation::CITEBRSR
--------------------
class: FL_BROWSER
type: HOLD_BROWSER
box: 250 40 170 370
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Bibliography keys
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 40 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @4->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 40 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 90 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @9+
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 90 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 140 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @8->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 140 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 190 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @2->
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 190 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BROWSER
type: NORMAL_BROWSER
box: 20 440 400 110
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Info
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: infoBrsr
callback:
argument:
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 160 570 130 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Citation style
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: style
callback:
argument:
==============================
--------------------

View File

@ -34,13 +34,9 @@ src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_preferences.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_print.C
src/frontends/xforms/forms/form_citation.C
src/frontends/xforms/forms/form_copyright.C
src/frontends/xforms/forms/form_preferences.C
src/frontends/xforms/forms/form_print.C
src/frontends/xforms/forms/form_tabular.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormUrl.C
src/frontends/xforms/Menubar_pimpl.C
src/gettext.h
src/insets/figinset.C

View File

@ -957,7 +957,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
inscmd.Read(this, lex);
Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.getContents(), inscmd.getOptions());
inset = new InsetCitation(inscmd.params());
} else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem");
inset = inscmd.Clone();
@ -971,7 +971,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
inset = new InsetLabel(inscmd.getCommand());
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.getCommand());
inset = new InsetUrl(inscmd.params());
} else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref"
@ -1190,8 +1190,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
inscmd.Read(this, lex);
Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.getContents(),
inscmd.getOptions());
inset = new InsetCitation(inscmd.params());
} else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem");
inset = inscmd.Clone();
@ -1206,7 +1205,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
inset = new InsetLabel(inscmd.getCommand());
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.getCommand());
inset = new InsetUrl(inscmd.params());
} else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref"

View File

@ -267,15 +267,11 @@ enum kb_action {
LFUN_INSET_LIST, // Lgb 20000627
LFUN_INSET_THEOREM, // Lgb 20000630
LFUN_CREATE_CITATION, // Angus 20000705
LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this comming from?
LFUN_INSERT_URL, // Angus 20000726
LFUN_LASTACTION /* this marks the end of the table */
};
std::ostream & operator<<(std::ostream &, kb_action);
#endif

View File

@ -7,7 +7,6 @@ _("Options|O");
_("Documents|D");
_("Help|H");
_("File|F");
_("File|F");
_("Options|O");
_("Help|H");
_("New...|N");

View File

@ -35,13 +35,14 @@ class DialogBase;
// Maybe this should be a UIFunc modelled on LyXFunc
class LyXView;
class InsetBibKey;
class InsetBibtex;
class InsetCitation;
class InsetInclude;
class InsetIndex;
class InsetBibKey;
class InsetCitation;
class InsetBibtex;
class InsetInfo;
class InsetTabular;
class InsetUrl;
/** Container of all dialogs and signals a LyXView needs or uses to access them
The list of dialog signals isn't comprehensive but should be a good guide
@ -113,6 +114,10 @@ public:
///
Signal1<void, string const &> createCitation;
///
Signal1<void, InsetUrl *> showUrl;
///
Signal1<void, string const &> createUrl;
///
Signal1<void, InsetBibtex *> showBibtex;
///
Signal1<void, InsetInfo *> showInfo;

View File

@ -7,6 +7,7 @@
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormTabular.h"
#include "FormUrl.h"
#ifdef __GNUG__
#pragma implementation
@ -20,6 +21,7 @@ Dialogs::Dialogs(LyXView * lv)
dialogs_.push_back(new FormPreferences(lv, this));
dialogs_.push_back(new FormPrint(lv, this));
dialogs_.push_back(new FormTabular(lv, this));
dialogs_.push_back(new FormUrl(lv, this));
// reduce the number of connections needed in
// dialogs by a simple connection here.

View File

@ -10,19 +10,17 @@
*/
#include <config.h>
#include <algorithm>
#include "gettext.h"
#include FORMS_H_LOCATION
#include "xform_macros.h"
#include "FormCitation.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "lyxfunc.h"
#include "insets/insetcite.h"
#include "form_citation.h"
#include "buffer.h"
#include "BufferView.h"
#include "Dialogs.h"
#include "FormCitation.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_citation.h"
#include "lyxfunc.h"
#include "xform_macros.h"
#include "insets/insetcite.h"
#include "support/filetools.h"
#ifdef __GNUG__
@ -41,7 +39,8 @@ C_GENERICCB(FormCitation, CancelCB)
C_GENERICCB(FormCitation, InputCB)
FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: dialog_(0), lv_(lv), d_(d), h_(0), inset_(0), dialogIsOpen(false)
: dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
inset_(0), dialogIsOpen(false)
{
// let the dialog be shown
// These are permanent connections so we won't bother
@ -59,7 +58,7 @@ FormCitation::~FormCitation()
void FormCitation::build()
{
dialog_ = build_citation();
dialog_ = build_citation();
}
@ -449,22 +448,23 @@ void FormCitation::apply()
{
if( lv_->buffer()->isReadonly() ) return;
string tmp;
string contents;
for( unsigned int i = 0; i < citekeys.size(); ++i ) {
if (i > 0) tmp += ", ";
tmp += citekeys[i];
if (i > 0) contents += ", ";
contents += citekeys[i];
}
textAfter = fl_get_input(dialog_->textAftr);
if( inset_ != 0 )
{
inset_->setContents( tmp );
inset_->setContents( contents );
inset_->setOptions( textAfter );
lv_->view()->updateInset( inset_, true );
} else {
string arg = tmp + '|' + textAfter;
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION, arg.c_str() );
InsetCommandParams p( "cite", contents, textAfter );
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION,
p.getAsString().c_str() );
}
}

View File

@ -67,7 +67,7 @@ private:
void show();
/// Hide the dialog.
void hide();
/// Not used but we've got to implement it.
///
void update();
//@}

View File

@ -0,0 +1,208 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#include <config.h>
#include "gettext.h"
#include FORMS_H_LOCATION
#include "BufferView.h"
#include "Dialogs.h"
#include "FormUrl.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_url.h"
#include "lyxfunc.h"
#include "xform_macros.h"
#include "insets/insetcommand.h"
#include "insets/inseturl.h"
#include "support/filetools.h"
#ifdef __GNUG__
#pragma implementation
#endif
C_RETURNCB(FormUrl, WMHideCB)
C_GENERICCB(FormUrl, OKCB)
C_GENERICCB(FormUrl, CancelCB)
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
: dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
inset_(0), dialogIsOpen(false)
{
// let the dialog be shown
// These are permanent connections so we won't bother
// storing a copy because we won't be disconnecting.
d->showUrl.connect(slot(this, &FormUrl::showInset));
d->createUrl.connect(slot(this, &FormUrl::createInset));
params = new InsetCommandParams();
}
FormUrl::~FormUrl()
{
free();
delete params;
}
void FormUrl::build()
{
dialog_ = build_url();
}
void FormUrl::showInset( InsetUrl * inset )
{
if( dialogIsOpen || inset == 0 ) return;
inset_ = inset;
ih_ = inset_->hide.connect(slot(this, &FormUrl::hide));
(*params) = inset->params();
show();
}
void FormUrl::createInset( string const & arg )
{
if( dialogIsOpen ) return;
params->setFromString( arg );
show();
}
void FormUrl::show()
{
if (!dialog_) {
build();
fl_set_form_atclose(dialog_->form_url,
C_FormUrlWMHideCB, 0);
}
update(); // make sure its up-to-date
dialogIsOpen = true;
if (dialog_->form_url->visible) {
fl_raise_form(dialog_->form_url);
} else {
fl_show_form(dialog_->form_url,
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_TRANSIENT,
_("Url"));
u_ = d_->updateBufferDependent.
connect(slot(this, &FormUrl::update));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormUrl::hide));
}
}
void FormUrl::update()
{
fl_set_input(dialog_->url, params->getContents().c_str());
fl_set_input(dialog_->name, params->getOptions().c_str());
if ( params->getCmdName() == "url" )
fl_set_button(dialog_->radio_html, 0);
else
fl_set_button(dialog_->radio_html, 1);
static int ow = -1, oh;
if (ow < 0) {
ow = dialog_->form_url->w;
oh = dialog_->form_url->h;
}
fl_set_form_minsize(dialog_->form_url, ow, oh);
fl_set_form_maxsize(dialog_->form_url, 2*ow, oh);
}
void FormUrl::apply()
{
if( lv_->buffer()->isReadonly() ) return;
params->setContents( fl_get_input(dialog_->url) );
params->setOptions( fl_get_input(dialog_->name) );
if (fl_get_button(dialog_->radio_html))
params->setCmdName("htmlurl");
else
params->setCmdName("url");
if( inset_ != 0 )
{
inset_->setParams( *params );
lv_->view()->updateInset( inset_, true );
} else {
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
params->getAsString().c_str() );
}
}
void FormUrl::hide()
{
if (dialog_
&& dialog_->form_url
&& dialog_->form_url->visible) {
fl_hide_form(dialog_->form_url);
u_.disconnect();
h_.disconnect();
}
// free up the dialog for another inset
inset_ = 0;
ih_.disconnect();
dialogIsOpen = false;
}
void FormUrl::free()
{
// we don't need to delete u and h here because
// hide() does that after disconnecting.
if (dialog_) {
if (dialog_->form_url
&& dialog_->form_url->visible) {
hide();
}
fl_free_form(dialog_->form_url);
delete dialog_;
dialog_ = 0;
}
}
int FormUrl::WMHideCB(FL_FORM * form, void *)
{
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormUrl * pre = static_cast<FormUrl*>(form->u_vdata);
pre->hide();
return FL_CANCEL;
}
void FormUrl::OKCB(FL_OBJECT * ob, long)
{
FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
pre->apply();
pre->hide();
}
void FormUrl::CancelCB(FL_OBJECT * ob, long)
{
FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
pre->hide();
}

View File

@ -0,0 +1,101 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#ifndef FORMURL_H
#define FORMURL_H
#include "DialogBase.h"
#include "LString.h"
class Dialogs;
class LyXView;
class InsetCommandParams;
class InsetUrl;
struct FD_form_url;
/** This class provides an XForms implementation of the FormUrl Dialog.
*/
class FormUrl : public DialogBase {
public:
/**@name Constructors and Destructors */
//@{
///
FormUrl(LyXView *, Dialogs *);
///
~FormUrl();
//@}
/**@name Real per-instance Callback Methods */
//@{
static int WMHideCB(FL_FORM *, void *);
static void OKCB(FL_OBJECT *, long);
static void CancelCB(FL_OBJECT *, long);
//@}
private:
FormUrl() {}
FormUrl(FormUrl &) : DialogBase() {}
/**@name Slot Methods */
//@{
/// Create the dialog if necessary, update it and display it.
void createInset( string const & );
///
void showInset( InsetUrl * );
///
void show();
/// Hide the dialog.
void hide();
///
void update();
//@}
/**@name Dialog internal methods */
//@{
/// Apply from dialog
void apply();
/// Build the dialog
void build();
///
FD_form_url * build_url();
/// Explicitly free the dialog.
void free();
//@}
/**@name Private Data */
//@{
/// Real GUI implementation.
FD_form_url * dialog_;
/** Which LyXFunc do we use?
We could modify Dialogs to have a visible LyXFunc* instead and
save a couple of bytes per dialog.
*/
LyXView * lv_;
/** Which Dialogs do we belong to?
Used so we can get at the signals we have to connect to.
*/
Dialogs * d_;
/// Update connection.
Connection u_;
/// Hide connection.
Connection h_;
/// inset::hide connection.
Connection ih_;
///
InsetUrl * inset_;
///
bool dialogIsOpen;
///
InsetCommandParams * params;
//@}
};
#endif

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_url
Width: 520
Height: 140
Number of Objects: 5
Number of Objects: 6
--------------------
class: FL_BOX
@ -44,7 +44,7 @@ label: URL
shortcut: Url|#U
resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast
name: url_name
name: url
callback:
argument:
@ -62,7 +62,7 @@ label: Name
shortcut: Name|#N
resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast
name: name_name
name: name
callback:
argument:
@ -86,7 +86,7 @@ argument:
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
type: NORMAL_BUTTON
box: 410 100 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
@ -94,12 +94,30 @@ alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Close|#C^[
shortcut: ^M
label: Cancel
shortcut: ^[
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
callback: C_InsetUrl_CloseUrlCB
name: cancel
callback: C_FormUrlCancelCB
argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 300 100 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: OK
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: ok
callback: C_FormUrlOKCB
argument: 0
==============================

View File

@ -23,7 +23,8 @@ SRCS := form_citation.fd \
form_copyright.fd \
form_preferences.fd \
form_print.fd \
form_tabular.fd
form_tabular.fd \
form_url.fd
OBJS := $(SRCS:.fd=.c)

View File

@ -14,8 +14,6 @@ libinsets_la_SOURCES = \
figinset.h \
form_graphics.C \
form_graphics.h \
form_url.C \
form_url.h \
inset.C \
insetbib.C \
insetbib.h \

View File

@ -350,10 +350,11 @@ void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
bool InsetBibtex::addDatabase(string const & db)
{
if (!contains(getContents(), db.c_str())) {
if (!getContents().empty())
addContents(",");
addContents(db);
string contents(getContents());
if (!contains(contents, db.c_str())) {
if (!contents.empty())
contents += ",";
setContents(contents + db);
return true;
}
return false;

View File

@ -20,8 +20,8 @@
#include "frontends/Dialogs.h"
#include "support/lstrings.h"
InsetCitation::InsetCitation(string const & key, string const & note)
: InsetCommand("cite", key, note)
InsetCitation::InsetCitation(InsetCommandParams const & p)
: InsetCommand(p)
{}
InsetCitation::~InsetCitation()

View File

@ -18,26 +18,21 @@
#include "insetcommand.h"
#include <sigc++/signal_system.h>
class Dialogs;
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
#endif
/** Used to insert citations
*/
class InsetCitation : public InsetCommand {
public:
///
explicit
InsetCitation(string const & key, string const & note = string());
InsetCitation(InsetCommandParams const &);
///
~InsetCitation();
///
Inset * Clone() const {
return new InsetCitation(getContents(), getOptions());
}
Inset * Clone() const { return new InsetCitation(params()); }
///
string getScreenLabel() const;
///

View File

@ -22,16 +22,67 @@ using std::ostream;
using std::endl;
InsetCommandParams::InsetCommandParams()
{}
InsetCommandParams::InsetCommandParams( string const & n,
string const & c,
string const & o )
: cmdname(n), contents(c), options(o)
{}
string InsetCommandParams::getAsString() const
{
string b(cmdname);
b += "|++|" + options + "|++|" + contents;
return b;
}
void InsetCommandParams::setFromString( string const & b )
{
string::size_type idx = b.find("|++|");
if( idx == string::npos ) return;
cmdname = b.substr(0, idx);
string tmp = b.substr(idx+4);
idx = tmp.find("|++|");
if( idx == string::npos ) {
options = tmp;
} else {
options = tmp.substr(0, idx);
contents = tmp.substr(idx+4);
}
}
InsetCommand::InsetCommand()
{}
InsetCommand::InsetCommand(string const & cmd, string const & arg,
string const & opt)
: cmdname(cmd), options(opt), contents(arg)
InsetCommand::InsetCommand( string const & n,
string const & c,
string const & o )
: p_(n, c, o)
{}
InsetCommand::InsetCommand( InsetCommandParams const & p )
: p_( p.getCmdName(), p.getContents(), p.getOptions() )
{}
void InsetCommand::setParams(InsetCommandParams const & p )
{
p_.setCmdName( p.getCmdName() );
p_.setContents( p.getContents() );
p_.setOptions( p.getOptions() );
}
// In lyxf3 this will be just LaTeX
void InsetCommand::Write(Buffer const *, ostream & os) const
{
@ -88,10 +139,9 @@ void InsetCommand::scanCommand(string const & cmd)
}
// Don't mess with this.
if (!tcmdname.empty()) cmdname = tcmdname;
if (!toptions.empty()) options = toptions;
if (!tcontents.empty()) setContents(tcontents);
// setContents is overloaded in InsetInclude
if (!tcmdname.empty()) setCmdName( tcmdname );
if (!toptions.empty()) setOptions( toptions );
if (!tcontents.empty()) setContents( tcontents );
if (lyxerr.debugging(Debug::PARSER))
lyxerr << "Command <" << cmd
@ -153,15 +203,15 @@ int InsetCommand::DocBook(Buffer const *, ostream &) const
Inset * InsetCommand::Clone() const
{
return new InsetCommand(cmdname, contents, options);
return new InsetCommand(getCmdName(), getContents(), getOptions());
}
string InsetCommand::getCommand() const
{
string s;
if (!cmdname.empty()) s += "\\"+cmdname;
if (!options.empty()) s += "["+options+']';
s += "{"+contents+'}';
if (!getCmdName().empty()) s += "\\"+getCmdName();
if (!getOptions().empty()) s += "["+getOptions()+']';
s += "{"+getContents()+'}';
return s;
}

View File

@ -24,14 +24,54 @@
* Similar to InsetLaTeX but having control of the basic structure of a
* LaTeX command: \name[options]{contents}.
*/
class InsetCommandParams {
public:
///
InsetCommandParams();
///
explicit
InsetCommandParams( string const & n,
string const & c = string(),
string const & o = string());
///
string const & getCmdName() const { return cmdname; }
///
string const & getOptions() const { return options; }
///
string const & getContents() const { return contents; }
///
void setCmdName( string const & n ) { cmdname = n; }
///
void setOptions(string const & o) { options = o; }
///
void setContents(string const & c) { contents = c; }
///
string getAsString() const;
///
void setFromString( string const & );
private:
///
string cmdname;
///
string contents;
///
string options;
};
class InsetCommand : public InsetButton {
public:
///
InsetCommand();
///
explicit
InsetCommand(string const & name, string const & arg = string(),
string const & opt = string());
InsetCommand(string const & n,
string const & c = string(),
string const & o = string());
///
explicit
InsetCommand(InsetCommandParams const &);
///
void Write(Buffer const *, std::ostream &) const;
@ -62,48 +102,28 @@ public:
confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale)
*/
virtual string getScreenLabel() const
{
return getCommand();
}
virtual string getScreenLabel() const { return getCommand(); }
/// Build the complete LaTeX command
string getCommand() const;
///
string const & getCmdName() const {
return cmdname;
}
string const & getCmdName() const { return p_.getCmdName(); }
///
string const & getOptions() const {
return options;
}
string const & getOptions() const { return p_.getOptions(); }
///
string const & getContents() const {
return contents;
}
string const & getContents() const { return p_.getContents(); }
///
void setCmdName(string const & n) {
cmdname = n;
}
void setCmdName(string const & n) { p_.setCmdName(n); }
///
void setOptions(string const & o) {
options = o;
}
void setOptions(string const & o) { p_.setOptions(o); }
///
virtual void setContents(string const & c) {
contents = c;
}
void setContents(string const & c) { p_.setContents(c); }
///
void addContents(string const & c) {
contents += c;
}
InsetCommandParams const & params() const { return p_; }
///
void setParams(InsetCommandParams const &);
private:
///
string cmdname;
///
string options;
///
string contents;
///
InsetCommandParams p_;
};
#endif

View File

@ -1,3 +1,4 @@
#include <config.h>
#include <cstdlib>
@ -334,11 +335,16 @@ string InsetInclude::getScreenLabel() const
}
void InsetInclude::setContents(string const & c)
string InsetInclude::getFileName() const
{
InsetCommand::setContents(c);
filename = MakeAbsPath(getContents(),
OnlyPath(getMasterFilename()));
return MakeAbsPath(getContents(),
OnlyPath(getMasterFilename()));
}
string InsetInclude::getMasterFilename() const
{
return master->fileName();
}

View File

@ -16,9 +16,8 @@
#endif
#include "insetcommand.h"
#include "buffer.h"
#include "support/filetools.h"
class Buffer;
struct LaTeXFeatures;
// Created by AAS 970521
@ -72,16 +71,11 @@ public:
bool display() const;
///
string getScreenLabel() const;
///
void setContents(string const & c);
///
void setFilename(string const & n) { setContents(n); }
string getMasterFilename() const;
///
string getMasterFilename() const { return master->fileName(); }
///
string getFileName() const {
return filename;
}
string getFileName() const;
/// In "input" mode uses \input instead of \include.
bool isInput() const { return flag == InsetInclude::INPUT; }
/// If this is true, the child file shouldn't be loaded by lyx
@ -129,8 +123,6 @@ private:
///
Buffer * master;
///
string filename;
///
mutable string include_label;
};

View File

@ -1,115 +1,27 @@
#include <config.h>
#include <cstdlib>
#ifdef __GNUG__
#pragma implementation
#endif
#include FORMS_H_LOCATION
#include "inseturl.h"
#include "LString.h"
#include "commandtags.h"
#include "debug.h"
#include "gettext.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
#include "LyXView.h"
#include "debug.h"
#include "frontends/Dialogs.h"
using std::ostream;
InsetUrl::InsetUrl(string const & cmd)
: fd_form_url(0)
{
scanCommand(cmd);
if (getCmdName() == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::InsetUrl(InsetCommand const & inscmd)
: fd_form_url(0)
{
setCmdName(inscmd.getCmdName());
setContents(inscmd.getContents());
setOptions(inscmd.getOptions());
if (getCmdName() == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::InsetUrl(string const & ins_name, string const & ins_cont,
string const & ins_opt)
: fd_form_url(0)
{
setCmdName(ins_name);
setContents(ins_cont);
setOptions(ins_opt);
if (ins_name == "url")
flag = InsetUrl::URL;
else
flag = InsetUrl::HTML_URL;
}
InsetUrl::InsetUrl(InsetCommandParams const & p)
: InsetCommand(p)
{}
InsetUrl::~InsetUrl()
{
if (fd_form_url) {
fl_hide_form(fd_form_url->form_url);
fl_free_form(fd_form_url->form_url);
fd_form_url = 0;
}
}
void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
{
Holder * holder = static_cast<Holder*>(ob->u_vdata);
InsetUrl * inset = holder->inset;
BufferView * bv = holder->view;
string url = fl_get_input(inset->fd_form_url->url_name);
string name = fl_get_input(inset->fd_form_url->name_name);
string cmdname;
if (fl_get_button(inset->fd_form_url->radio_html))
cmdname = "htmlurl";
else
cmdname = "url";
Buffer * buffer = bv->buffer();
if ((url != inset->getContents() ||
name != inset->getOptions() ||
cmdname != inset->getCmdName())
&& !(buffer->isReadonly()) ) {
buffer->markDirty();
inset->setContents(url);
inset->setOptions(name);
inset->setCmdName(cmdname);
if (cmdname == "url")
inset->flag = InsetUrl::URL;
else
inset->flag = InsetUrl::HTML_URL;
bv->updateInset(inset, true);
}
if (inset->fd_form_url) {
fl_hide_form(inset->fd_form_url->form_url);
fl_free_form(inset->fd_form_url->form_url);
inset->fd_form_url = 0;
}
}
extern "C"
void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
{
InsetUrl::CloseUrlCB(ob, data);
hide();
}
@ -121,57 +33,23 @@ char const * InsetUrl::EditMessage() const
void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
{
static int ow = -1, oh;
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
if (!fd_form_url) {
fd_form_url = create_form_form_url();
holder.inset = this;
fd_form_url->button_close->u_vdata = &holder;
fl_set_form_atclose(fd_form_url->form_url,
CancelCloseBoxCB, 0);
}
holder.view = bv;
fl_set_input(fd_form_url->url_name, getContents().c_str());
fl_set_input(fd_form_url->name_name, getOptions().c_str());
switch(flag) {
case InsetUrl::URL:
fl_set_button(fd_form_url->radio_html, 0);
break;
case InsetUrl::HTML_URL:
fl_set_button(fd_form_url->radio_html, 1);
break;
}
if (fd_form_url->form_url->visible) {
fl_raise_form(fd_form_url->form_url);
} else {
fl_show_form(fd_form_url->form_url,
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_FULLBORDER, _("Insert Url"));
if (ow < 0) {
ow = fd_form_url->form_url->w;
oh = fd_form_url->form_url->h;
}
fl_set_form_minsize(fd_form_url->form_url, ow, oh);
}
bv->owner()->getDialogs()->showUrl( this );
}
string InsetUrl::getScreenLabel() const
{
string temp;
if (flag == InsetUrl::HTML_URL)
temp += _("HtmlUrl: ");
if( getCmdName() == "url" )
temp = _("Url: ");
else
temp += _("Url: ");
if(!getOptions().empty()) {
temp = _("HtmlUrl: ");
if(!getOptions().empty())
temp += getOptions();
} else {
temp += getContents();
}
else
temp += getContents();
return temp;
}

View File

@ -16,61 +16,39 @@
#endif
#include "insetcommand.h"
#include "buffer.h"
#include "form_url.h"
#include <sigc++/signal_system.h>
struct LaTeXFeatures;
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
#endif
/** The url inset
*/
class InsetUrl : public InsetCommand {
public:
///
enum Url_Flags {
///
URL,
///
HTML_URL
};
///
InsetUrl() : InsetCommand("url"), fd_form_url(0) {
flag = InsetUrl::URL;
}
///
explicit
InsetUrl(string const &);
///
explicit
InsetUrl(InsetCommand const &);
///
InsetUrl(string const &, string const &, string const &);
InsetUrl(InsetCommandParams const &);
///
~InsetUrl();
///
Inset * Clone() const { return new InsetUrl(getCommand()); }
Inset * Clone() const { return new InsetUrl(params()); }
///
Inset::Code LyxCode() const { return Inset::URL_CODE; }
///
void Validate(LaTeXFeatures &) const;
///
void Edit(BufferView *, int, int, unsigned int);
///
EDITABLE Editable() const {
return IS_EDITABLE;
}
///
char const * EditMessage() const;
///
bool display() const { return false; }
///
string getScreenLabel() const;
///
InsetUrl::Url_Flags getFlag() const { return flag; }
EDITABLE Editable() const { return IS_EDITABLE; }
///
void setFlag(InsetUrl::Url_Flags f) { flag = f; }
char const * EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
void gotoLabel();
bool display() const { return false; }
///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
@ -81,20 +59,7 @@ public:
///
int DocBook(Buffer const *, std::ostream &) const;
///
static void CloseUrlCB(FL_OBJECT *, long data);
private:
///
struct Holder {
InsetUrl * inset;
BufferView * view;
};
///
Holder holder;
///
Url_Flags flag;
///
FD_form_url * fd_form_url;
Signal0<void> hide;
};
#endif

View File

@ -2071,18 +2071,28 @@ string LyXFunc::Dispatch(int ac,
case LFUN_HTMLURL:
case LFUN_URL:
{
InsetCommand * new_inset;
InsetCommandParams p;
if (action == LFUN_HTMLURL)
new_inset = new InsetUrl("htmlurl", "", "");
p.setCmdName("htmlurl");
else
new_inset = new InsetUrl("url", "", "");
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
delete new_inset;
p.setCmdName("url");
owner->getDialogs()->createUrl( p.getAsString() );
}
break;
case LFUN_INSERT_URL:
{
InsetCommandParams p;
p.setFromString( argument );
InsetUrl * inset = new InsetUrl( p );
if (!owner->view()->insertInset(inset))
delete inset;
else
owner->view()->updateInset( inset, true );
}
break;
case LFUN_INSET_TEXT:
{
InsetText * new_inset = new InsetText;
@ -2493,10 +2503,10 @@ string LyXFunc::Dispatch(int ac,
case LFUN_INSERT_CITATION:
{
string keys = token(argument, '|', 0);
string text = token(argument, '|', 1);
InsetCommandParams p;
p.setFromString( argument );
InsetCitation * inset = new InsetCitation( keys, text );
InsetCitation * inset = new InsetCitation( p );
if (!owner->view()->insertInset(inset))
delete inset;
else

View File

@ -23,6 +23,7 @@
#include "lyxrc.h"
#include "layout.h"
#include "tex-strings.h"
#include "buffer.h"
#include "bufferparams.h"
#include "support/FileInfo.h"
#include "support/LAssert.h"