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