- FL_OBJECT * obj;
- FD_citation_form * fdui = (FD_citation_form *) fl_calloc(1, sizeof(*fdui));
-
- // NOTE: dialog geometry is set in setSize().
- // Initial size is simply non-zero.
- fdui->form = fl_bgn_form(FL_NO_BOX, 10, 10);
- fdui->box = obj = fl_add_box(FL_UP_BOX, 0, 0, 10, 10, "");
-
- fdui->citeBrsr = obj =
- fl_add_browser(FL_HOLD_BROWSER, 0, 0, 10, 10, _("Citation keys"));
- fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::CITEBRSR);
-
- fdui->bibBrsr = obj =
- fl_add_browser(FL_HOLD_BROWSER, 0, 0, 10, 10, _("Bibliography keys"));
- fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::BIBBRSR);
-
- fdui->addBtn = obj =
- fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@4->");
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::ADD);
-
- fdui->delBtn = obj =
- fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@9+");
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::DELETE);
-
- fdui->upBtn = obj =
- fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@8->");
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::UP);
-
- fdui->downBtn = obj =
- fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@2->");
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::DOWN);
-
- fdui->infoBrsr = obj =
- fl_add_browser(FL_NORMAL_BROWSER, 0, 0, 10, 10, _("Info"));
- fl_set_object_lsize(obj, FL_NORMAL_SIZE) ;
- fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
-
- fdui->textAftr = obj =
- fl_add_input(FL_NORMAL_INPUT, 0, 0, 10, 10, _("Text after"));
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-
- fdui->ok = obj =
- fl_add_button(FL_RETURN_BUTTON, 0, 0, 10, 10, _("OK"));
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::OK);
-
- fdui->cancel = obj =
- fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, idex(_("Cancel|^[")));
- fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, citation_cb, InsetCitation::CANCEL);
-
- fl_end_form();
-
- return fdui;
-}
-
-
-InsetCitation::InsetCitation(string const & key, string const & note)
- : InsetCommand("cite", key, note)
-{
-}
-
-
-InsetCitation::~InsetCitation()
-{
- if(citation_form && citation_form->form
- && citation_form->form->visible
- && citation_form->form->u_vdata == &holder)
- fl_hide_form(citation_form->form);
-}
-
-
-void InsetCitation::Edit( BufferView * bv, int, int, unsigned int )
-{
- if ( !citation_form ) {
- citation_form = create_form_citation_form();
- fl_set_form_atclose( citation_form->form,
- CancelCloseBoxCB, 0 );
- }
-
- holder.inset = this;
- holder.view = bv;
-
- citation_form->form->u_vdata = &holder;
-
- // update the browsers, noting the number of keys.
- bibkeys_info = bv->buffer()->getBibkeyList();
- bibkeys.clear();
- insetkeys.clear();
- for( unsigned int i = 0; i < bibkeys_info.size(); ++i )
- bibkeys.push_back(bibkeys_info[i].first);
-
- string tmp;
- string keys = getContents();
- keys = frontStrip( split(keys, tmp, ',') );
- while( !tmp.empty() ) {
- insetkeys.push_back( tmp );
- keys = frontStrip( split(keys, tmp, ',') );
- }
-
- updateBrowser( citation_form->bibBrsr, bibkeys );
- updateBrowser( citation_form->citeBrsr, insetkeys );
- fl_clear_browser( citation_form->infoBrsr );
-
- // No keys have been selected yet, so...
- setBibButtons( citation_form, OFF );
- setCiteButtons( citation_form, OFF );
-
- int noKeys = max( bibkeys.size(), insetkeys.size() );
-
- // Place bounds, so that 4 <= noKeys <= 15
- noKeys = max( 4, min(15, noKeys) );
-
- // Re-size the form to accommodate the new browser size
- int size = 20 * noKeys;
- bool bibPresent = ( bibkeys.size() > 0 );
- setSize(citation_form, size, bibPresent);
-
- fl_set_input( citation_form->textAftr, getOptions().c_str() );
- if( holder.view->buffer()->isReadonly() )
- fl_deactivate_object( citation_form->textAftr );
-
- if( citation_form->form->visible ) {
- fl_raise_form( citation_form->form );