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;
68 void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
70 InsetUrl *inset = (InsetUrl*) ob->u_vdata;
71 string url = fl_get_input(inset->url_name);
72 string name = fl_get_input(inset->name_name);
74 if (fl_get_button(inset->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;
97 fl_hide_form(inset->form);
103 void InsetUrl::Edit(int, int)
105 if(current_view->currentBuffer()->isReadonly())
110 form = fl_bgn_form(FL_NO_BOX, 530, 170);
111 obj = fl_add_box(FL_UP_BOX,0,0,530,170,"");
112 url_name = obj = fl_add_input(FL_NORMAL_INPUT,50,30,460,30,idex(_("Url|#U")));
113 fl_set_button_shortcut(obj,scex(_("Url|#U")),1);
114 name_name = obj = fl_add_input(FL_NORMAL_INPUT,50,80,460,30,idex(_("Name|#N")));
115 fl_set_button_shortcut(obj,scex(_("Name|#N")),1);
116 obj = fl_add_button(FL_RETURN_BUTTON,360,130,100,30,idex(_("Close|#C^[^M")));
117 fl_set_button_shortcut(obj,scex(_("Close|#C^[^M")),1);
119 fl_set_object_callback(obj,CloseUrlCB,0);
120 radio_html = obj = fl_add_checkbutton(FL_PUSH_BUTTON,50,130,240,30,idex(_("HTML type|#H")));
121 fl_set_button_shortcut(obj,scex(_("HTML type|#H")),1);
122 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
124 fl_set_form_atclose(form, CancelCloseBoxCB, 0);
126 fl_set_input(url_name, getContents().c_str());
127 fl_set_input(name_name, getOptions().c_str());
130 fl_set_button(radio_html, 0);
132 case InsetUrl::HTML_URL:
133 fl_set_button(radio_html, 1);
140 fl_show_form(form, FL_PLACE_MOUSE,
141 FL_FULLBORDER, _("Insert Url"));
146 string InsetUrl::getScreenLabel() const
149 if (flag == InsetUrl::HTML_URL)
150 temp += _("HtmlUrl: ");
153 temp += getContents();
154 if(!getOptions().empty()) {
156 temp += getOptions();
162 int InsetUrl::Latex(FILE *file, signed char fragile)
165 int res = Latex(latex_output, fragile);
166 fprintf(file, "%s", latex_output.c_str());
172 int InsetUrl::Latex(string &file, signed char fragile)
174 if (!getOptions().empty())
175 file += getOptions() + ' ';
179 file += "\\url{" + getContents() + '}';
185 int InsetUrl::Linuxdoc(string &file)
187 file += "<"+ getCmdName() +
188 " url=\"" + getContents()+"\"" +
189 " name=\"" + getOptions() +"\">";
195 int InsetUrl::DocBook(string &file)
197 file += "<ulink url=\"" + getContents() + "\">" +
198 getOptions() +"</ulink>";
204 void InsetUrl::Validate(LaTeXFeatures& features) const