Choose labels from other documents

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2752 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-09-13 09:57:06 +00:00
parent 5fa24cd3b7
commit 1bfe247634
8 changed files with 114 additions and 30 deletions

View File

@ -1,3 +1,7 @@
2001-09-07 Dekel Tsur <dekelts@tau.ac.il>
* ControlRef.C (getBufferList, getBufferNum): New methods
2001-09-12 Angus Leeming <a.leeming@ic.ac.uk>
* ControlInset.h (disconnectOnApply): new method. Defines the behaviour

View File

@ -12,6 +12,7 @@
*/
#include <config.h>
#include <algorithm>
#ifdef __GNUG__
#pragma implementation
@ -24,8 +25,13 @@
#include "LyXView.h"
#include "buffer.h"
#include "lyxfunc.h"
#include "bufferlist.h"
using SigC::slot;
using std::vector;
using std::find;
extern BufferList bufferlist;
ControlRef::ControlRef(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_REF_INSERT)
@ -35,9 +41,12 @@ ControlRef::ControlRef(LyXView & lv, Dialogs & d)
}
std::vector<string> const ControlRef::getLabelList() const
vector<string> const ControlRef::getLabelList(string const & name) const
{
return lv_.buffer()->getLabelList();
Buffer * buffer = bufferlist.getBuffer(name);
if (!buffer)
buffer = lv_.buffer();
return buffer->getLabelList();
}
@ -53,3 +62,20 @@ void ControlRef::gotoBookmark() const
lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
}
vector<string> const ControlRef::getBufferList() const
{
return bufferlist.getFileNames();
}
int ControlRef::getBufferNum() const
{
vector<string> buffers = bufferlist.getFileNames();
string const name = lv_.buffer()->fileName();
vector<string>::const_iterator cit =
find(buffers.begin(), buffers.end(), name);
if (cit == buffers.end())
return 0;
return cit - buffers.begin();
}

View File

@ -29,11 +29,15 @@ public:
ControlRef(LyXView &, Dialogs &);
///
std::vector<string> const getLabelList() const;
std::vector<string> const getLabelList(string const &) const;
///
void gotoRef(string const &) const;
///
void gotoBookmark() const;
///
std::vector<string> const getBufferList() const;
///
int getBufferNum() const;
};
#endif // CONTROLREF_H

View File

@ -1,3 +1,10 @@
2001-09-07 Dekel Tsur <dekelts@tau.ac.il>
* forms/form_ref.fd: Add buffer button.
* FormRef.C (update): Handle the buffer button.
(input): Ditto
2001-09-13 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* forms/form_graphics.fd: complete rewrite of the dialog

View File

@ -24,6 +24,8 @@
#include "form_ref.h"
#include "xforms_helpers.h"
#include "insets/insetref.h"
#include "helper_funcs.h" // getStringFromVector
#include "support/lstrings.h" // frontStrip, strip
using std::find;
using std::max;
@ -90,7 +92,13 @@ void FormRef::update()
setEnabled(dialog_->type, true);
}
refs_ = controller().getLabelList();
string const choice =
" " + getStringFromVector(controller().getBufferList(), " | ") + " ";
fl_clear_choice(dialog_->buffer);
fl_addto_choice(dialog_->buffer, choice.c_str());
fl_set_choice(dialog_->buffer, controller().getBufferNum() + 1);
refs_ = controller().getLabelList(string());
updateBrowser(refs_);
}
@ -119,18 +127,20 @@ void FormRef::updateBrowser(vector<string> const & akeys) const
setEnabled(dialog_->sort, true);
string ref = fl_get_input(dialog_->ref);
vector<string>::const_iterator cit =
find(keys.begin(), keys.end(), ref);
vector<string>::const_iterator cit = (ref.empty())
? keys.begin()
: find(keys.begin(), keys.end(), ref);
if (cit == keys.end()) {
cit = keys.begin();
fl_set_input(dialog_->ref, cit->c_str());
} else if (ref.empty())
fl_deselect_browser(dialog_->browser);
} else {
if (ref.empty())
fl_set_input(dialog_->ref, cit->c_str());
int const i = static_cast<int>(cit - keys.begin());
fl_set_browser_topline(dialog_->browser, max(i-5, 1));
fl_select_browser_line(dialog_->browser, i+1);
}
}
}
@ -185,10 +195,15 @@ ButtonPolicy::SMInput FormRef::input(FL_OBJECT * ob, long)
fl_set_object_lcol(dialog_->ref, FL_BLACK);
} else if (ob == dialog_->button_update ||
ob == dialog_->sort) {
ob == dialog_->sort ||
ob == dialog_->buffer) {
if (ob == dialog_->button_update)
refs_ = controller().getLabelList();
if (ob == dialog_->button_update ||
ob == dialog_->buffer) {
string const name =
frontStrip(strip(fl_get_choice_text(dialog_->buffer)));
refs_ = controller().getLabelList(name);
}
fl_freeze_form(form());
updateBrowser(refs_);

View File

@ -31,14 +31,14 @@ FD_form_ref * FormRef::build_ref()
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, 40, 260, 90, 30, idex(_(dummy)));
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 260, 90, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Sort|#S");
fdui->sort = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 170, 260, 30, 30, idex(_(dummy)));
fdui->sort = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 110, 260, 30, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
@ -92,6 +92,15 @@ FD_form_ref * FormRef::build_ref()
}
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
{
char const * const dummy = N_("Buffer|#B");
fdui->buffer = obj = fl_add_choice(FL_NORMAL_CHOICE, 190, 260, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;

View File

@ -28,6 +28,7 @@ struct FD_form_ref {
FL_OBJECT *button_cancel;
FL_OBJECT *button_apply;
FL_OBJECT *button_restore;
FL_OBJECT *buffer;
};
#endif /* FD_form_ref_h_ */

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_ref
Width: 530
Height: 340
Number of Objects: 12
Number of Objects: 13
--------------------
class: FL_BOX
@ -46,12 +46,12 @@ resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_South
name: browser
callback: C_FormBaseInputCB
argument:
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 40 260 90 30
box: 10 260 90 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -64,12 +64,12 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_update
callback: C_FormBaseInputCB
argument:
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 170 260 30 30
box: 110 260 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_RIGHT
@ -82,7 +82,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: sort
callback: C_FormBaseInputCB
argument:
argument: 0
--------------------
class: FL_INPUT
@ -136,7 +136,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: type
callback: C_FormBaseInputCB
argument:
argument: 0
--------------------
class: FL_BUTTON
@ -154,7 +154,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_go
callback: C_FormBaseInputCB
argument:
argument: 0
--------------------
class: FL_BUTTON
@ -172,7 +172,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
callback: C_FormBaseOKCB
argument:
argument: 0
--------------------
class: FL_BUTTON
@ -190,7 +190,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_cancel
callback: C_FormBaseCancelCB
argument:
argument: 0
--------------------
class: FL_BUTTON
@ -208,7 +208,7 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
callback: C_FormBaseApplyCB
argument:
argument: 0
--------------------
class: FL_BUTTON
@ -226,7 +226,25 @@ resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_restore
callback: C_FormBaseRestoreCB
argument:
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 190 260 100 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_RIGHT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Buffer|#B
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: buffer
callback: C_FormBaseInputCB
argument: 0
==============================
create_the_forms