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