9 #include FORMS_H_LOCATION
12 #include "commandtags.h"
14 #include "LaTeXFeatures.h"
15 #include "lyx_gui_misc.h" // CancelCloseBoxCB
17 extern BufferView *current_view;
18 extern void UpdateInset(Inset* inset, bool mark_dirty = true);
20 InsetUrl::InsetUrl(string const & cmd)
24 if (getCmdName() == "url")
27 flag = InsetUrl::HTML_URL;
31 InsetUrl::InsetUrl(InsetCommand const &inscmd)
34 setCmdName(inscmd.getCmdName());
35 setContents(inscmd.getContents());
36 setOptions(inscmd.getOptions());
37 if (getCmdName() == "url")
40 flag = InsetUrl::HTML_URL;
44 InsetUrl::InsetUrl(string const &ins_name,string const &ins_cont,
45 string const &ins_opt)
49 setContents(ins_cont);
51 if (ins_name == "url")
54 flag = InsetUrl::HTML_URL;
61 fl_hide_form(fd_form_url->form_url);
62 fl_free_form(fd_form_url->form_url);
68 void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
70 InsetUrl *inset = (InsetUrl*) ob->u_vdata;
71 string url = fl_get_input(inset->fd_form_url->url_name);
72 string name = fl_get_input(inset->fd_form_url->name_name);
74 if (fl_get_button(inset->fd_form_url->radio_html))
79 Buffer *buffer = current_view->currentBuffer();
81 if ((url != inset->getContents() ||
82 name != inset->getOptions() ||
83 cmdname != inset->getCmdName())
84 && !(buffer->isReadonly()) ) {
86 inset->setContents(url);
87 inset->setOptions(name);
88 inset->setCmdName(cmdname);
90 inset->flag = InsetUrl::URL;
92 inset->flag = InsetUrl::HTML_URL;
96 if (inset->fd_form_url) {
97 fl_hide_form(inset->fd_form_url->form_url);
98 inset->fd_form_url = 0;
102 extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT *ob, long)
104 InsetUrl::CloseUrlCB(ob,0);
107 void InsetUrl::Edit(int, int)
109 static int ow = -1, oh;
111 if(current_view->currentBuffer()->isReadonly())
115 fd_form_url = create_form_form_url();
116 fd_form_url->button_close->u_vdata = this;
117 fl_set_form_atclose(fd_form_url->form_url,CancelCloseBoxCB, 0);
119 fl_set_input(fd_form_url->url_name, getContents().c_str());
120 fl_set_input(fd_form_url->name_name, getOptions().c_str());
123 fl_set_button(fd_form_url->radio_html, 0);
125 case InsetUrl::HTML_URL:
126 fl_set_button(fd_form_url->radio_html, 1);
130 if (fd_form_url->form_url->visible) {
131 fl_raise_form(fd_form_url->form_url);
133 fl_show_form(fd_form_url->form_url,
134 FL_PLACE_MOUSE | FL_FREE_SIZE,
135 FL_FULLBORDER, _("Insert Url"));
137 ow = fd_form_url->form_url->w;
138 oh = fd_form_url->form_url->h;
140 fl_set_form_minsize(fd_form_url->form_url, ow, oh);
145 string InsetUrl::getScreenLabel() const
148 if (flag == InsetUrl::HTML_URL)
149 temp += _("HtmlUrl: ");
152 temp += getContents();
153 if(!getOptions().empty()) {
155 temp += getOptions();
161 int InsetUrl::Latex(FILE *file, signed char fragile)
164 int res = Latex(latex_output, fragile);
165 fprintf(file, "%s", latex_output.c_str());
171 int InsetUrl::Latex(string &file, signed char fragile)
173 if (!getOptions().empty())
174 file += getOptions() + ' ';
178 file += "\\url{" + getContents() + '}';
184 int InsetUrl::Linuxdoc(string &file)
186 file += "<"+ getCmdName() +
187 " url=\"" + getContents()+"\"" +
188 " name=\"" + getOptions() +"\">";
194 int InsetUrl::DocBook(string &file)
196 file += "<ulink url=\"" + getContents() + "\">" +
197 getOptions() +"</ulink>";
203 void InsetUrl::Validate(LaTeXFeatures& features) const