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