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