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