]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormGraphics.C
Fix crash.
[lyx.git] / src / frontends / xforms / FormGraphics.C
1 /**
2  * \file FormGraphics.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Baruch Even
7  * \author Herbert Voss
8  * \author Rob Lahaye
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "xformsBC.h"
20 #include "ControlGraphics.h"
21 #include "FormGraphics.h"
22 #include "forms/form_graphics.h"
23
24 #include "checkedwidgets.h"
25 #include "input_validators.h"
26 #include "Tooltips.h"
27 #include "xforms_helpers.h"
28
29 #include "debug.h" // for lyxerr
30 #include "lyxrc.h" // for lyxrc.display_graphics
31
32 #include "insets/insetgraphicsParams.h"
33
34 #include "controllers/helper_funcs.h" // for getStringFromVector
35
36 #include "frontends/Alert.h"
37
38 #include "support/lstrings.h"  // for strToDbl & tostr
39 #include "support/lyxlib.h"  // for float_equal
40 #include "support/filetools.h"  // for MakeAbsPath etc
41
42 #include FORMS_H_LOCATION
43
44 using std::endl;
45 using std::vector;
46
47
48 namespace {
49
50 // Bound the number of input characters
51 int const SIZE_MAXDIGITS = 10;
52 int const FILENAME_MAXCHARS = 1024;
53
54 string defaultUnit("cm");
55
56 } // namespace anon
57
58
59 typedef FormCB<ControlGraphics, FormDB<FD_graphics> > base_class;
60
61 FormGraphics::FormGraphics()
62         : base_class(_("Graphics"), false)
63 {}
64
65
66 void FormGraphics::redraw()
67 {
68         if (form() && form()->visible)
69                 fl_redraw_form(form());
70         else
71                 return;
72         FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
73         if (outer_form && outer_form->visible)
74                 fl_redraw_form(outer_form);
75 }
76
77
78 void FormGraphics::build()
79 {
80         dialog_.reset(build_graphics(this));
81
82         // Manage the ok, apply, restore and cancel/close buttons
83         bc().setOK(dialog_->button_ok);
84         bc().setApply(dialog_->button_apply);
85         bc().setCancel(dialog_->button_close);
86         bc().setRestore(dialog_->button_restore);
87
88         // the file section
89         file_.reset(build_graphics_file(this));
90
91         // disable for read-only documents
92         bc().addReadOnly(file_->button_browse);   
93         bc().addReadOnly(file_->check_aspectratio);
94         bc().addReadOnly(file_->check_draft);
95         bc().addReadOnly(file_->check_nounzip);
96
97         // check validity of "length + unit" input
98         addCheckedGlueLength(bc(), file_->input_width);
99         addCheckedGlueLength(bc(), file_->input_height);
100
101         // trigger an input event for cut&paste with middle mouse button.
102         setPrehandler(file_->input_filename);
103         setPrehandler(file_->input_lyxscale);
104         setPrehandler(file_->input_width);
105         setPrehandler(file_->input_height);
106
107         // for activate ok/apply immediately upon input
108         fl_set_input_return(file_->input_filename, FL_RETURN_CHANGED);
109         fl_set_input_return(file_->input_lyxscale, FL_RETURN_CHANGED);
110         fl_set_input_return(file_->input_width, FL_RETURN_CHANGED);
111         fl_set_input_return(file_->input_height, FL_RETURN_CHANGED);
112
113         fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
114         fl_set_input_filter(file_->input_lyxscale, fl_unsigned_float_filter);
115
116         // width default is scaling, thus unsigned integer input
117         fl_set_input_filter(file_->input_width, fl_unsigned_int_filter);
118         fl_set_input_maxchars(file_->input_height, SIZE_MAXDIGITS);
119         
120         string const display_List =
121                 _("Default|Monochrome|Grayscale|Color|Do not display");
122         fl_addto_choice(file_->choice_display, display_List.c_str());
123         
124         string const width_list = _("Scale%%|") + choice_Length_All;
125         fl_addto_choice(file_->choice_width, width_list.c_str());
126
127         fl_addto_choice(file_->choice_height, choice_Length_All.c_str());
128
129         // set up the tooltips for the filesection
130         string str = _("The file you want to insert.");
131         tooltips().init(file_->input_filename, str);
132         str = _("Browse the directories.");
133         tooltips().init(file_->button_browse, str);
134
135         str = _("Scale the image to inserted percentage value.");
136         tooltips().init(file_->input_lyxscale, str);
137         str = _("Select display mode for this image.");
138         tooltips().init(file_->choice_display, str);
139
140         str = _("Set the image width to the inserted value.");
141         tooltips().init(file_->input_width, str);
142         str = _("Select unit for width; Scale% for scaling whole image.");
143         tooltips().init(file_->choice_width, str);
144         str = _("Set the image height to the inserted value.");
145         tooltips().init(file_->input_height, str);
146         str = _("Select unit for height.");
147         tooltips().init(file_->choice_height, str);
148         str = _("Do not distort the image. " 
149                 "Keep image within \"width\" by \"height\" and obey "
150                 "aspect ratio.");
151         tooltips().init(file_->check_aspectratio, str);
152         str = _("Pass a filename like \"file.eps.gz\" to the LaTeX output. "
153                 "Useful when LaTeX should unzip the file. Needs an additional "
154                 "file like \"file.eps.bb\" which holds the values for "
155                 "the bounding box.");
156         tooltips().init(file_->check_nounzip, str);
157         str = _("Show image only as a rectangle of the original size.");
158         tooltips().init(file_->check_draft, str);
159
160         // the bounding box selection
161         bbox_.reset(build_graphics_bbox(this));
162
163         // disable for read-only documents
164         bc().addReadOnly(bbox_->button_getBB);
165         bc().addReadOnly(bbox_->check_clip);
166
167         // check validity of "length + unit" input
168         addCheckedLyXLength(bc(), bbox_->input_bb_x1, bbox_->text_X);
169
170         // trigger an input event for cut&paste with middle mouse button.
171         setPrehandler(bbox_->input_bb_x0);
172         setPrehandler(bbox_->input_bb_y0);
173         setPrehandler(bbox_->input_bb_x1);
174         setPrehandler(bbox_->input_bb_y1);
175
176         // for activate ok/apply immediately upon input
177         fl_set_input_return(bbox_->input_bb_x0, FL_RETURN_CHANGED);
178         fl_set_input_return(bbox_->input_bb_y0, FL_RETURN_CHANGED);
179         fl_set_input_return(bbox_->input_bb_x1, FL_RETURN_CHANGED);
180         fl_set_input_return(bbox_->input_bb_y1, FL_RETURN_CHANGED);
181
182         fl_set_input_filter(bbox_->input_bb_x0, fl_unsigned_float_filter);
183         fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter);
184         fl_set_input_filter(bbox_->input_bb_y1, fl_unsigned_float_filter);
185
186         string const bb_units = "bp|cm|mm|in";
187         fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str());
188
189         // set up the tooltips for the bounding-box-section
190         str = _("The lower left x-value of the bounding box.");
191         tooltips().init(bbox_->input_bb_x0, str);
192         str = _("The lower left y-value of the bounding box.");
193         tooltips().init(bbox_->input_bb_y0, str);
194         str = _("The upper right x-value of the bounding box; "
195                 "only this input field allows length + unit, e.g. 5cm "
196                 "and sets the unit for the other input fields.");
197         tooltips().init(bbox_->input_bb_x1, str);
198         str = _("The upper right y-value of the bounding box.");
199         tooltips().init(bbox_->input_bb_y1, str);
200         str = _("Select unit for the bounding box values.");
201         tooltips().init(bbox_->choice_bb_units, str);
202
203         str = _("Read the image coordinates new from file. For (e)ps-file "
204                 "the bounding box is read, otherwise the imagesize in pixels. "
205                 "Default unit is \"bp\", the PostScript's b(ig) p(oint).");
206         tooltips().init(bbox_->button_getBB, str);
207
208         str = _("Clip image to the bounding box values.");
209         tooltips().init(bbox_->check_clip, str);
210
211         // the extra section
212         extra_.reset(build_graphics_extra(this));
213
214         // disable for read-only documents
215         bc().addReadOnly(extra_->input_rotate_angle);
216         bc().addReadOnly(extra_->choice_origin);
217         bc().addReadOnly(extra_->check_subcaption);
218         bc().addReadOnly(extra_->input_special);
219
220         // trigger an input event for cut&paste with middle mouse button.
221         setPrehandler(extra_->input_rotate_angle);
222         setPrehandler(extra_->input_subcaption);
223         setPrehandler(extra_->input_special);
224
225         fl_set_input_return(extra_->input_rotate_angle, FL_RETURN_CHANGED);
226         fl_set_input_return(extra_->input_subcaption, FL_RETURN_CHANGED);
227         fl_set_input_return(extra_->input_special, FL_RETURN_CHANGED);
228
229         fl_set_input_filter(extra_->input_rotate_angle, fl_float_filter);
230
231         using namespace frnt;
232         vector<RotationOriginPair> origindata = getRotationOriginData();
233
234         // Store the identifiers for later
235         origins_ = getSecond(origindata);
236
237         string const choice = "Default|" + getStringFromVector(getFirst(origindata), "|");
238         fl_addto_choice(extra_->choice_origin, choice.c_str());
239
240         // set up the tooltips for the extra section
241         str = _("Insert the rotation angle in degrees. "
242                 "Positive value rotates anti-clockwise, "
243                 "negative value clockwise.");
244         tooltips().init(extra_->input_rotate_angle, str);
245         str = _("Insert the point of origin for rotation.");
246         tooltips().init(extra_->choice_origin, str);
247         str = _("Enables use of subfigure with its own caption.");
248         tooltips().init(extra_->check_subcaption, str);
249         str = _("Insert the optional subfigure caption.");
250         tooltips().init(extra_->input_subcaption, str);
251         str = _("Add any additional latex option, which is defined in the "
252                 "graphicx-package and not mentioned in the gui's tabfolders.");
253         tooltips().init(extra_->input_special, str);
254
255         // add the different tabfolders
256         fl_addto_tabfolder(dialog_->tabfolder, _("File"), file_->form);
257         fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box"), bbox_->form);
258         fl_addto_tabfolder(dialog_->tabfolder, _("Extra"), extra_->form);
259
260         // work-around xforms bug re update of folder->x, folder->y coords.
261         setPrehandler(dialog_->tabfolder);
262
263         // set the right default unit
264         switch (lyxrc.default_papersize) {
265         case BufferParams::PAPER_DEFAULT: break;
266         case BufferParams::PAPER_USLETTER:
267         case BufferParams::PAPER_LEGALPAPER:
268         case BufferParams::PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
269         case BufferParams::PAPER_A3PAPER:
270         case BufferParams::PAPER_A4PAPER:
271         case BufferParams::PAPER_A5PAPER:
272         case BufferParams::PAPER_B5PAPER: defaultUnit = "cm"; break;
273         }
274 }
275
276
277 void FormGraphics::apply()
278 {
279         // Create the parameters structure and fill the data from the dialog.
280         InsetGraphicsParams & igp = controller().params();
281
282         // the file section
283         igp.filename = getString(file_->input_filename);
284
285         igp.lyxscale = strToInt(getString(file_->input_lyxscale));
286         if (igp.lyxscale == 0) {
287                 igp.lyxscale = 100;
288         }
289         
290         switch (fl_get_choice(file_->choice_display)) {
291         case 5:
292                 igp.display = grfx::NoDisplay;
293                 break;
294         case 4:
295                 igp.display = grfx::ColorDisplay;
296                 break;
297         case 3:
298                 igp.display = grfx::GrayscaleDisplay;
299                 break;
300         case 2:
301                 igp.display = grfx::MonochromeDisplay;
302                 break;
303         case 1:
304                 igp.display = grfx::DefaultDisplay;
305         }
306
307         // first item in choice_width means scaling
308         if (fl_get_choice(file_->choice_width) == 1) {
309                 igp.scale = strToDbl(getString(file_->input_width));
310                 if (lyx::float_equal(igp.scale, 0.0, 0.05)) {
311                         igp.scale = 100.0;
312                 }
313                 igp.width = LyXLength();
314         } else {
315                 igp.scale = 0.0;
316                 igp.width = LyXLength(getLengthFromWidgets(file_->input_width,
317                                                            file_->choice_width));
318         }
319         igp.height = LyXLength(getLengthFromWidgets(file_->input_height,
320                                                     file_->choice_height));
321         igp.keepAspectRatio = fl_get_button(file_->check_aspectratio);
322
323         igp.draft = fl_get_button(file_->check_draft);
324         igp.noUnzip = fl_get_button(file_->check_nounzip);
325
326         // the bb section
327         if (!controller().bbChanged) {
328                 // don't write anything         
329                 igp.bb.erase();
330         } else {
331                 // allow length + unit input only for x1 input field
332                 string x1_str = "0";
333                 if (!getString(bbox_->input_bb_x1).empty()) {
334                         x1_str = getLengthFromWidgets(bbox_->input_bb_x1,
335                                                       bbox_->choice_bb_units);
336                         LyXLength x1 = LyXLength(x1_str);
337                         x1_str = x1.asString();
338
339                         string unit;
340                         switch (x1.unit()) {
341                         case LyXLength::IN:
342                                 unit = "in";
343                                 break;
344                         case LyXLength::MM:
345                                 unit = "mm";
346                                 break;
347                         case LyXLength::CM:
348                                 unit = "cm";
349                                 break;
350                         case LyXLength::BP:
351                         default:
352                                 unit = "bp";
353                         }
354                         fl_set_choice_text(bbox_->choice_bb_units, unit.c_str());
355                 }
356
357                 string bb;
358                 if (getString(bbox_->input_bb_x0).empty())
359                         bb = "0";
360                 else
361                         bb = getLengthFromWidgets(bbox_->input_bb_x0,
362                                                   bbox_->choice_bb_units);
363
364                 bb += " ";
365
366                 if (getString(bbox_->input_bb_y0).empty())
367                         bb += "0";
368                 else
369                         bb += getLengthFromWidgets(bbox_->input_bb_y0,
370                                                   bbox_->choice_bb_units);
371
372                 bb += " " + x1_str + " ";
373
374                 if (getString(bbox_->input_bb_y1).empty())
375                         bb += "0";
376                 else
377                         bb += getLengthFromWidgets(bbox_->input_bb_y1,
378                                                    bbox_->choice_bb_units); 
379
380                 igp.bb = bb;
381         }
382         igp.clip = fl_get_button(bbox_->check_clip);
383
384         // the extra section
385         igp.rotateAngle = strToDbl(getString(extra_->input_rotate_angle));
386         
387         // map angle into -360 (clock-wise) to +360 (counter clock-wise)
388         while (igp.rotateAngle <= -360.0) {
389                 igp.rotateAngle += 360.0;
390         }
391         while (igp.rotateAngle >=  360.0) {
392                 igp.rotateAngle -= 360.0;
393         }
394         fl_set_input(extra_->input_rotate_angle, tostr(igp.rotateAngle).c_str());
395
396         int const origin_pos = fl_get_choice(extra_->choice_origin);
397         if (origin_pos == 1) {
398                 igp.rotateOrigin.erase();
399         } else {
400                 igp.rotateOrigin = origins_[origin_pos - 2];
401         }
402
403         igp.subcaption = fl_get_button(extra_->check_subcaption);
404         igp.subcaptionText = getString(extra_->input_subcaption);
405
406         igp.special = getString(extra_->input_special);
407 }
408
409
410 void FormGraphics::update() {
411         // Update dialog with details from inset
412         InsetGraphicsParams & igp = controller().params();
413
414         // the file section
415         fl_set_input(file_->input_filename, igp.filename.c_str());
416         fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
417
418         switch (igp.display) {
419         case grfx::NoDisplay:
420                 fl_set_choice(file_->choice_display, 5);
421                 break;
422         case grfx::ColorDisplay:
423                 fl_set_choice(file_->choice_display, 4);
424                 break;
425         case grfx::GrayscaleDisplay:
426                 fl_set_choice(file_->choice_display, 3);
427                 break;
428         case grfx::MonochromeDisplay:
429                 fl_set_choice(file_->choice_display, 2);
430                 break;
431         case grfx::DefaultDisplay:
432                 fl_set_choice(file_->choice_display, 1);
433         }
434
435         // set width input fields according to scaling or width/height input
436         if (igp.scale) {
437                 fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
438                 fl_set_input_maxchars(file_->input_width, 0);
439                 fl_set_input(file_->input_width, tostr(igp.scale).c_str());
440                 fl_set_choice(file_->choice_width, 1);
441         } else {
442                 fl_set_input_filter(file_->input_width, NULL);
443                 fl_set_input_maxchars(file_->input_width, SIZE_MAXDIGITS);
444                 updateWidgetsFromLength(file_->input_width, file_->choice_width,
445                                         igp.width, defaultUnit);
446         }
447
448         updateWidgetsFromLength(file_->input_height, file_->choice_height,
449                                 igp.height, defaultUnit);
450
451         // disable height input in case of scaling
452         bool const disable_height = igp.scale != 0.0;
453         setEnabled(file_->input_height, !disable_height);
454         setEnabled(file_->choice_height, !disable_height);
455         
456         fl_set_button(file_->check_aspectratio, igp.keepAspectRatio);
457         fl_set_button(file_->check_draft, igp.draft);
458         fl_set_button(file_->check_nounzip, igp.noUnzip);
459
460         // disable aspectratio button in case of scaling or one of width/height
461         // is empty
462         bool const disable_aspectRatio = disable_height ||
463                                 getString(file_->input_width).empty() ||
464                                 getString(file_->input_height).empty();
465         setEnabled(file_->check_aspectratio, !disable_aspectRatio);
466
467         // the bb section
468         // set the bounding box values, if exists. First we need the whole
469         // path, because the controller knows nothing about the doc-dir
470         updateBB(igp.filename, igp.bb);
471         fl_set_button(bbox_->check_clip, igp.clip);
472
473         // the extra section
474         fl_set_input(extra_->input_rotate_angle,
475                      tostr(igp.rotateAngle).c_str());
476
477         int origin_pos;
478         if (igp.rotateOrigin.empty()) {
479                 origin_pos = 1;
480         } else {
481                 origin_pos = 2 + findPos(origins_, igp.rotateOrigin);
482         }
483         fl_set_choice(extra_->choice_origin, origin_pos);
484
485         fl_set_button(extra_->check_subcaption, igp.subcaption);
486         fl_set_input(extra_->input_subcaption, igp.subcaptionText.c_str());
487         setEnabled(extra_->input_subcaption,
488                    fl_get_button(extra_->check_subcaption));
489         fl_set_input(extra_->input_special, igp.special.c_str());
490
491         // open dialog in the file-tab, whenever filename is empty
492         if (igp.filename.empty()) {
493                 fl_set_folder(dialog_->tabfolder, file_->form);
494         }
495 }
496
497
498 void FormGraphics::updateBB(string const & filename, string const & bb_inset)
499 {
500         // Update dialog with details from inset
501         // set the bounding box values, if exists. First we need the whole
502         // path, because the controller knows nothing about the doc-dir
503         controller().bbChanged = false;
504         if (bb_inset.empty()) {
505                 lyxerr[Debug::GRAPHICS]
506                         << "FormGraphics::updateBB() [no BoundingBox]" << endl;
507                 string const bb = controller().readBB(filename);
508                 if (!bb.empty()) {
509                         // get the values from the file
510                         // in this case we always have the point-unit
511                         fl_set_input(bbox_->input_bb_x0,
512                                      token(bb,' ',0).c_str());
513                         fl_set_input(bbox_->input_bb_y0,
514                                      token(bb,' ',1).c_str());
515                         fl_set_input(bbox_->input_bb_x1,
516                                      token(bb,' ',2).c_str());
517                         fl_set_input(bbox_->input_bb_y1,
518                                      token(bb,' ',3).c_str());
519
520                 } else {
521                         // no bb from file
522                         fl_set_input(bbox_->input_bb_x0, bb.c_str());
523                         fl_set_input(bbox_->input_bb_y0, bb.c_str());
524                         fl_set_input(bbox_->input_bb_x1, bb.c_str());
525                         fl_set_input(bbox_->input_bb_y1, bb.c_str());
526                 }
527                 // "bp"
528                 fl_set_choice(bbox_->choice_bb_units, 1);
529
530         } else {
531                 // get the values from the inset
532                 lyxerr[Debug::GRAPHICS]
533                         << "FormGraphics::updateBB(): igp has BoundingBox"
534                         << " ["<< bb_inset << "]" << endl;
535                 controller().bbChanged = true;
536
537                 LyXLength anyLength;
538                 anyLength = LyXLength(token(bb_inset,' ',0));
539                 updateWidgetsFromLength(bbox_->input_bb_x0,
540                                         bbox_->choice_bb_units,anyLength,"bp");
541                 anyLength = LyXLength(token(bb_inset,' ',1));
542                 updateWidgetsFromLength(bbox_->input_bb_y0,
543                                         bbox_->choice_bb_units,anyLength,"bp");
544                 anyLength = LyXLength(token(bb_inset,' ',2));
545                 updateWidgetsFromLength(bbox_->input_bb_x1,
546                                         bbox_->choice_bb_units,anyLength,"bp");
547                 anyLength = LyXLength(token(bb_inset,' ',3));
548                 updateWidgetsFromLength(bbox_->input_bb_y1,
549                                         bbox_->choice_bb_units,anyLength,"bp");
550         }
551 }
552
553
554 ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
555 {
556         // the file section
557         if (ob == file_->button_browse) {
558                 // Get the filename from the dialog
559                 string const in_name = getString(file_->input_filename);
560                 string const out_name = controller().Browse(in_name);
561                 lyxerr[Debug::GRAPHICS]
562                         << "[FormGraphics]out_name: " << out_name << endl;
563                 if (out_name != in_name && !out_name.empty()) {
564                         fl_set_input(file_->input_filename, out_name.c_str());
565                 }
566                 if (controller().isFilenameValid(out_name) &&
567                     !controller().bbChanged) {
568                         updateBB(out_name, string());
569                 }
570         } else if (ob == file_->input_width || ob == file_->input_height) {
571                 // disable aspectratio button in case of scaling or one of
572                 // width/height is empty
573                 bool const disable = fl_get_choice(file_->choice_width) == 1 ||
574                                     getString(file_->input_width).empty() ||
575                                     getString(file_->input_height).empty();
576                 setEnabled(file_->check_aspectratio, !disable);
577         } else if (ob == file_->choice_width) {
578                 // disable height input in case of scaling
579                 bool const scaling = fl_get_choice(file_->choice_width) == 1;
580                 setEnabled(file_->input_height, !scaling);
581                 setEnabled(file_->choice_height, !scaling);
582                 
583                 // allow only integer intput for scaling; float otherwise
584                 if (scaling) {
585                         fl_set_input_filter(file_->input_width, fl_unsigned_int_filter);
586                         fl_set_input_maxchars(file_->input_width, 0);
587                 } else {
588                         fl_set_input_filter(file_->input_width, NULL);
589                         fl_set_input_maxchars(file_->input_width, SIZE_MAXDIGITS);
590                 }
591
592                 // disable aspectratio button in case of scaling or height
593                 // input is empty
594                 bool const disable_aspectratio =
595                         scaling || getString(file_->input_height).empty();
596                 setEnabled(file_->check_aspectratio, !disable_aspectratio);
597         // the bb section
598         } else if (!controller().bbChanged &&
599                    (ob == bbox_->check_clip  || ob == bbox_->choice_bb_units ||
600                     ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 ||
601                     ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) {
602                 controller().bbChanged = true;
603         } else if (ob == bbox_->button_getBB) {
604                 string const filename = getString(file_->input_filename);
605                 if (!filename.empty()) {
606                         string bb = controller().readBB(filename);
607                         if (!bb.empty()) {
608                                 fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
609                                 fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
610                                 fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
611                                 fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
612                                 fl_set_choice_text(bbox_->choice_bb_units, "bp");
613                         }
614                         controller().bbChanged = false;
615                 } else {
616                         fl_set_input(bbox_->input_bb_x0, "");
617                         fl_set_input(bbox_->input_bb_y0, "");
618                         fl_set_input(bbox_->input_bb_x1, "");
619                         fl_set_input(bbox_->input_bb_y1, "");
620                         fl_set_choice_text(bbox_->choice_bb_units, "bp");
621                 }
622         // the extra section
623         } else if (ob == extra_->check_subcaption) {
624                 setEnabled(extra_->input_subcaption,
625                            fl_get_button(extra_->check_subcaption));
626
627         }
628
629         return ButtonPolicy::SMI_VALID;
630 }