1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000-2001 The LyX Team.
8 * ======================================================
10 * \file FormGraphics.C
11 * \author Baruch Even, baruch.even@writeme.com
12 * \author Herbert Voss, voss@perce.de
18 #pragma implementation
22 #include "ControlGraphics.h"
23 #include "FormGraphics.h"
24 #include "form_graphics.h"
26 #include "xforms_helpers.h"
27 #include "input_validators.h"
28 #include "debug.h" // for lyxerr
29 #include "support/lstrings.h" // for strToDbl & tostr
30 #include "support/FileInfo.h"
31 #include "support/filetools.h" // for MakeAbsPath etc
32 #include "insets/insetgraphicsParams.h"
33 #include "lyxrc.h" // for lyxrc.display_graphics
39 // Bound the number of input characters
40 int const SCALE_MAXDIGITS = 3;
41 int const WIDTH_MAXDIGITS = 10;
42 int const HEIGHT_MAXDIGITS = 10;
43 int const ROTATE_MAXCHARS = 4;
44 int const FILENAME_MAXCHARS = 1024;
45 string defaultUnit = "cm";
50 typedef FormCB<ControlGraphics, FormDB<FD_form_graphics> > base_class;
52 FormGraphics::FormGraphics(ControlGraphics & c)
53 : base_class(c, _("Graphics"), false)
57 void FormGraphics::redraw()
59 if (form() && form()->visible)
60 fl_redraw_form(form());
63 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
64 if (outer_form && outer_form->visible)
65 fl_redraw_form(outer_form);
69 void FormGraphics::build()
71 dialog_.reset(build_graphics());
73 // Manage the ok, apply, restore and cancel/close buttons
74 bc().setOK(dialog_->button_ok);
75 bc().setApply(dialog_->button_apply);
76 bc().setCancel(dialog_->button_cancel);
77 bc().setRestore(dialog_->button_restore);
80 file_.reset(build_file());
82 fl_set_input_return (file_->input_filename, FL_RETURN_CHANGED);
83 fl_set_input_return (file_->input_subcaption, FL_RETURN_CHANGED);
84 fl_set_input_return (file_->input_rotate_angle, FL_RETURN_CHANGED);
85 fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
86 fl_set_input_maxchars(file_->input_rotate_angle, ROTATE_MAXCHARS);
87 fl_set_input_filter(file_->input_rotate_angle, fl_float_filter);
89 string const choice_origin =
91 "leftTop|leftBottom|leftBaseline|" // lt lb lB
92 "centerTop|centerBottom|centerBaseline|" // ct cb cB
93 "rightTop|rightBottom|rightBaseline"; // rt rb rB
94 fl_addto_choice(file_->choice_origin, choice_origin.c_str());
96 bc().addReadOnly(file_->button_browse);
97 bc().addReadOnly(file_->check_subcaption);
98 bc().addReadOnly(file_->check_rotate);
99 bc().addReadOnly(file_->button_draft);
100 bc().addReadOnly(file_->button_nounzip);
102 // the lyxview section
103 lyxview_.reset(build_lyxview());
105 fl_set_input_return (lyxview_->input_lyxwidth, FL_RETURN_CHANGED);
106 fl_set_input_return (lyxview_->input_lyxheight, FL_RETURN_CHANGED);
107 fl_set_input_return (lyxview_->input_lyxscale, FL_RETURN_CHANGED);
109 fl_addto_choice(lyxview_->choice_width_lyxwidth, choice_Length_All.c_str());
110 fl_addto_choice(lyxview_->choice_width_lyxheight, choice_Length_All.c_str());
112 bc().addReadOnly(lyxview_->radio_pref);
113 bc().addReadOnly(lyxview_->radio_mono);
114 bc().addReadOnly(lyxview_->radio_gray);
115 bc().addReadOnly(lyxview_->radio_color);
116 bc().addReadOnly(lyxview_->radio_nodisplay);
119 size_.reset(build_size());
121 fl_set_input_return (size_->input_scale, FL_RETURN_CHANGED);
122 fl_set_input_return (size_->input_width, FL_RETURN_CHANGED);
123 fl_set_input_return (size_->input_height, FL_RETURN_CHANGED);
125 fl_set_input_maxchars(size_->input_scale, SCALE_MAXDIGITS);
126 fl_set_input_maxchars(size_->input_width, WIDTH_MAXDIGITS);
127 fl_set_input_maxchars(size_->input_height, HEIGHT_MAXDIGITS);
129 fl_set_input_filter(size_->input_scale, fl_unsigned_float_filter);
131 fl_addto_choice(size_->choice_width_units, choice_Length_All.c_str());
132 fl_addto_choice(size_->choice_height_units, choice_Length_All.c_str());
134 bc().addReadOnly(size_->button_asis);
135 bc().addReadOnly(size_->button_wh);
136 bc().addReadOnly(size_->button_scale);
137 bc().addReadOnly(size_->check_aspectratio);
139 // the bounding box selection
140 bbox_.reset(build_bbox());
141 fl_set_input_return (bbox_->input_bb_x0, FL_RETURN_CHANGED);
142 fl_set_input_return (bbox_->input_bb_y0, FL_RETURN_CHANGED);
143 fl_set_input_return (bbox_->input_bb_x1, FL_RETURN_CHANGED);
144 fl_set_input_return (bbox_->input_bb_y1, FL_RETURN_CHANGED);
146 fl_set_input_filter(bbox_->input_bb_x0, fl_unsigned_float_filter);
147 fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter);
148 fl_set_input_filter(bbox_->input_bb_x1, fl_unsigned_float_filter);
150 string const bb_units = "pt|cm|in";
151 fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str());
152 bc().addReadOnly(bbox_->button_getBB);
153 bc().addReadOnly(bbox_->button_clip);
155 // the rotate section
156 special_.reset(build_special());
158 fl_set_input_return (special_->input_special, FL_RETURN_CHANGED);
160 // add the different tabfolders
161 fl_addto_tabfolder(dialog_->tabFolder, _("File"), file_->form);
162 fl_addto_tabfolder(dialog_->tabFolder, _("LyX View"), lyxview_->form);
163 fl_addto_tabfolder(dialog_->tabFolder, _("LaTeX Size"), size_->form);
164 fl_addto_tabfolder(dialog_->tabFolder, _("Bounding Box"), bbox_->form);
165 fl_addto_tabfolder(dialog_->tabFolder, _("Extras"), special_->form);
169 void FormGraphics::apply()
171 // Create the parameters structure and fill the data from the dialog.
172 InsetGraphicsParams & igp = controller().params();
175 igp.filename = getStringFromInput(file_->input_filename);
176 igp.subcaption = fl_get_button(file_->check_subcaption);
177 igp.subcaptionText = getStringFromInput(file_->input_subcaption);
178 igp.rotate = fl_get_button(file_->check_rotate);
180 strToDbl(getStringFromInput(file_->input_rotate_angle));
181 while (igp.rotateAngle < 0.0 || igp.rotateAngle > 360.0) {
182 if (igp.rotateAngle < 0.0) {
183 igp.rotateAngle += 360.0;
184 } else if (igp.rotateAngle > 360.0) {
185 igp.rotateAngle -= 360.0;
188 if (fl_get_choice(file_->choice_origin) > 0)
189 igp.rotateOrigin = fl_get_choice_text(file_->choice_origin);
191 igp.rotateOrigin = string();
192 igp.draft = fl_get_button(file_->button_draft);
193 igp.noUnzip = fl_get_button(file_->button_nounzip);
195 // the lyxview section
196 if (fl_get_button(lyxview_->radio_pref))
197 igp.display = InsetGraphicsParams::DEFAULT;
198 else if (fl_get_button(lyxview_->radio_mono))
199 igp.display = InsetGraphicsParams::MONOCHROME;
200 else if (fl_get_button(lyxview_->radio_gray))
201 igp.display = InsetGraphicsParams::GRAYSCALE;
202 else if (fl_get_button(lyxview_->radio_color))
203 igp.display = InsetGraphicsParams::COLOR;
204 else if (fl_get_button(lyxview_->radio_nodisplay))
205 igp.display = InsetGraphicsParams::NONE;
207 if (fl_get_button(lyxview_->button_lyxasis))
208 igp.lyxsize_type = InsetGraphicsParams::DEFAULT_SIZE;
209 else if (fl_get_button(lyxview_->button_lyxwh))
210 igp.lyxsize_type = InsetGraphicsParams::WH;
212 igp.lyxsize_type = InsetGraphicsParams::SCALE;
213 igp.lyxwidth = LyXLength(getLengthFromWidgets(lyxview_->input_lyxwidth,
214 lyxview_->choice_width_lyxwidth));
215 igp.lyxheight = LyXLength(getLengthFromWidgets(lyxview_->input_lyxheight,
216 lyxview_->choice_width_lyxheight));
217 igp.lyxscale = strToInt(getStringFromInput(lyxview_->input_lyxscale));
220 if (fl_get_button(size_->button_asis))
221 igp.size_type = InsetGraphicsParams::DEFAULT_SIZE;
222 else if (fl_get_button(size_->button_wh))
223 igp.size_type = InsetGraphicsParams::WH;
225 igp.size_type = InsetGraphicsParams::SCALE;
226 igp.width = LyXLength(getLengthFromWidgets(size_->input_width,
227 size_->choice_width_units));
228 igp.height = LyXLength(getLengthFromWidgets(size_->input_height,
229 size_->choice_height_units));
230 igp.scale = strToInt(getStringFromInput(size_->input_scale));
231 igp.keepAspectRatio = fl_get_button(size_->check_aspectratio);
234 if (!controller().bbChanged) // different to the original one?
235 igp.bb = string(); // don't write anything
238 if (getStringFromInput(bbox_->input_bb_x0).empty())
241 bb = getLengthFromWidgets(bbox_->input_bb_x0,
242 bbox_->choice_bb_units)+" ";
243 if (getStringFromInput(bbox_->input_bb_y0).empty())
246 bb += (getLengthFromWidgets(bbox_->input_bb_y0,
247 bbox_->choice_bb_units)+" ");
248 if (getStringFromInput(bbox_->input_bb_x1).empty())
251 bb += (getLengthFromWidgets(bbox_->input_bb_x1,
252 bbox_->choice_bb_units)+" ");
253 if (getStringFromInput(bbox_->input_bb_y1).empty())
256 bb += (getLengthFromWidgets(bbox_->input_bb_y1,
257 bbox_->choice_bb_units)+" ");
260 igp.clip = fl_get_button(bbox_->button_clip);
262 // the special section
263 igp.special = getStringFromInput(special_->input_special);
267 void FormGraphics::update() {
268 if (lyxrc.default_papersize < 3)
269 defaultUnit = string("in");
270 // Update dialog with details from inset
271 InsetGraphicsParams & igp = controller().params();
274 fl_set_input(file_->input_filename, igp.filename.c_str());
275 fl_set_button(file_->check_subcaption, igp.subcaption);
276 fl_set_input(file_->input_subcaption, igp.subcaptionText.c_str());
277 setEnabled(file_->input_subcaption,
278 fl_get_button(file_->check_subcaption));
279 fl_set_button(file_->check_rotate, igp.rotate);
280 fl_set_input(file_->input_rotate_angle,
281 tostr(igp.rotateAngle).c_str());
282 if (igp.rotateOrigin.empty())
283 fl_set_choice(file_->choice_origin,0);
285 fl_set_choice_text(file_->choice_origin,igp.rotateOrigin.c_str());
286 setEnabled(file_->input_rotate_angle,
287 fl_get_button(file_->check_rotate));
288 setEnabled(file_->choice_origin,
289 fl_get_button(file_->check_rotate));
290 fl_set_button(file_->button_draft, igp.draft);
291 fl_set_button(file_->button_nounzip, igp.noUnzip);
293 // the lyxview section
294 switch (igp.display) {
295 case InsetGraphicsParams::DEFAULT:
296 fl_set_button(lyxview_->radio_pref, 1);
298 case InsetGraphicsParams::MONOCHROME:
299 fl_set_button(lyxview_->radio_mono, 1);
301 case InsetGraphicsParams::GRAYSCALE:
302 fl_set_button(lyxview_->radio_gray, 1);
304 case InsetGraphicsParams::COLOR:
305 fl_set_button(lyxview_->radio_color, 1);
307 case InsetGraphicsParams::NONE:
308 fl_set_button(lyxview_->radio_nodisplay, 1);
311 updateWidgetsFromLength(lyxview_->input_lyxwidth,
312 lyxview_->choice_width_lyxwidth, igp.lyxwidth,defaultUnit);
313 updateWidgetsFromLength(lyxview_->input_lyxheight,
314 lyxview_->choice_width_lyxheight, igp.lyxheight,defaultUnit);
315 fl_set_input(lyxview_->input_lyxscale, tostr(igp.lyxscale).c_str());
316 switch (igp.lyxsize_type) {
317 case InsetGraphicsParams::DEFAULT_SIZE: {
318 fl_set_button(lyxview_->button_lyxasis,1);
319 setEnabled(lyxview_->input_lyxwidth, 0);
320 setEnabled(lyxview_->choice_width_lyxwidth, 0);
321 setEnabled(lyxview_->input_lyxheight, 0);
322 setEnabled(lyxview_->choice_width_lyxheight, 0);
323 setEnabled(lyxview_->input_lyxscale, 0);
326 case InsetGraphicsParams::WH: {
327 fl_set_button(lyxview_->button_lyxwh, 1);
328 setEnabled(lyxview_->input_lyxwidth, 1);
329 setEnabled(lyxview_->choice_width_lyxwidth, 1);
330 setEnabled(lyxview_->input_lyxheight, 1);
331 setEnabled(lyxview_->choice_width_lyxheight, 1);
332 setEnabled(lyxview_->input_lyxscale, 0);
335 case InsetGraphicsParams::SCALE: {
336 fl_set_button(lyxview_->button_lyxscale, 1);
337 setEnabled(lyxview_->input_lyxwidth, 0);
338 setEnabled(lyxview_->choice_width_lyxwidth, 0);
339 setEnabled(lyxview_->input_lyxheight, 0);
340 setEnabled(lyxview_->choice_width_lyxheight, 0);
341 setEnabled(lyxview_->input_lyxscale, 1);
347 // Update the draft and clip mode
348 updateWidgetsFromLength(size_->input_width,
349 size_->choice_width_units,igp.width,defaultUnit);
350 updateWidgetsFromLength(size_->input_height,
351 size_->choice_height_units,igp.height,defaultUnit);
352 fl_set_input(size_->input_scale, tostr(igp.scale).c_str());
353 switch (igp.size_type) {
354 case InsetGraphicsParams::DEFAULT_SIZE: {
355 fl_set_button(size_->button_asis,1);
356 setEnabled(size_->input_width, 0);
357 setEnabled(size_->choice_width_units, 0);
358 setEnabled(size_->input_height, 0);
359 setEnabled(size_->choice_height_units, 0);
360 setEnabled(size_->check_aspectratio, 0);
361 setEnabled(size_->input_scale, 0);
364 case InsetGraphicsParams::WH: {
365 fl_set_button(size_->button_wh, 1);
366 setEnabled(size_->input_width, 1);
367 setEnabled(size_->choice_width_units, 1);
368 setEnabled(size_->input_height, 1);
369 setEnabled(size_->choice_height_units, 1);
370 setEnabled(size_->check_aspectratio, 1);
371 setEnabled(size_->input_scale, 0);
374 case InsetGraphicsParams::SCALE: {
375 fl_set_button(size_->button_scale, 1);
376 setEnabled(size_->input_width, 0);
377 setEnabled(size_->choice_width_units, 0);
378 setEnabled(size_->input_height, 0);
379 setEnabled(size_->choice_height_units, 0);
380 setEnabled(size_->check_aspectratio, 0);
381 setEnabled(size_->input_scale, 1);
385 fl_set_button(size_->check_aspectratio, igp.keepAspectRatio);
388 // set the bounding box values, if exists. First we need the whole
389 // path, because the controller knows nothing about the doc-dir
390 controller().bbChanged = false;
391 if (igp.bb.empty()) {
392 lyxerr[Debug::GRAPHICS] << "update:: no BoundingBox" << endl;
393 string const fileWithAbsPath =
394 MakeAbsPath(igp.filename, OnlyPath(igp.filename));
395 string const bb = controller().readBB(fileWithAbsPath);
397 // get the values from the file
398 // in this case we always have the point-unit
399 fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
400 fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
401 fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
402 fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
403 } else { // no bb from file
404 fl_set_input(bbox_->input_bb_x0, bb.c_str());
405 fl_set_input(bbox_->input_bb_y0, bb.c_str());
406 fl_set_input(bbox_->input_bb_x1, bb.c_str());
407 fl_set_input(bbox_->input_bb_y1, bb.c_str());
409 fl_set_choice(bbox_->choice_bb_units, 1); // "pt"
410 } else { // get the values from the inset
411 lyxerr[Debug::GRAPHICS] << "update:: igp has BoundingBox" << endl;
412 controller().bbChanged = true;
414 anyLength = LyXLength(token(igp.bb,' ',0));
415 updateWidgetsFromLength(bbox_->input_bb_x0,
416 bbox_->choice_bb_units,anyLength,"pt");
417 anyLength = LyXLength(token(igp.bb,' ',1));
418 updateWidgetsFromLength(bbox_->input_bb_y0,
419 bbox_->choice_bb_units,anyLength,"pt");
420 anyLength = LyXLength(token(igp.bb,' ',2));
421 updateWidgetsFromLength(bbox_->input_bb_x1,
422 bbox_->choice_bb_units,anyLength,"pt");
423 anyLength = LyXLength(token(igp.bb,' ',3));
424 updateWidgetsFromLength(bbox_->input_bb_y1,
425 bbox_->choice_bb_units,anyLength,"pt");
427 fl_set_button(bbox_->button_clip, igp.clip);
429 // the special section
430 fl_set_input(special_->input_special, igp.special.c_str());
436 bool isValid(FL_OBJECT * ob)
438 string const input = getStringFromInput(ob);
439 return input.empty() || isValidLength(input) || isStrDbl(input);
446 ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
449 if (ob == file_->button_browse) {
450 // Get the filename from the dialog
451 string const in_name = getStringFromInput(file_->input_filename);
452 string const out_name = controller().Browse(in_name);
453 if (out_name != in_name && !out_name.empty()) {
454 fl_set_input(file_->input_filename, out_name.c_str());
456 } else if (ob == file_->check_subcaption) {
457 setEnabled(file_->input_subcaption,
458 fl_get_button(file_->check_subcaption));
459 } else if (ob == file_->check_rotate) {
460 setEnabled(file_->input_rotate_angle,
461 fl_get_button(file_->check_rotate));
462 setEnabled(file_->choice_origin,
463 fl_get_button(file_->check_rotate));
465 // the lyxview section
466 } else if (ob == lyxview_->button_lyxasis) {
467 setEnabled(lyxview_->input_lyxwidth, 0);
468 setEnabled(lyxview_->choice_width_lyxwidth, 0);
469 setEnabled(lyxview_->input_lyxheight, 0);
470 setEnabled(lyxview_->choice_width_lyxheight, 0);
471 setEnabled(lyxview_->input_lyxscale, 0);
472 } else if (ob == lyxview_->button_lyxwh) {
473 setEnabled(lyxview_->input_lyxwidth, 1);
474 setEnabled(lyxview_->choice_width_lyxwidth, 1);
475 setEnabled(lyxview_->input_lyxheight, 1);
476 setEnabled(lyxview_->choice_width_lyxheight, 1);
477 setEnabled(lyxview_->input_lyxscale, 0);
478 } else if (ob == lyxview_->button_lyxscale) {
479 setEnabled(lyxview_->input_lyxwidth, 0);
480 setEnabled(lyxview_->choice_width_lyxwidth, 0);
481 setEnabled(lyxview_->input_lyxheight, 0);
482 setEnabled(lyxview_->choice_width_lyxheight, 0);
483 setEnabled(lyxview_->input_lyxscale, 1);
484 } else if (ob == lyxview_->button_latex_values) {
485 LyXLength dummy = LyXLength(getLengthFromWidgets(size_->input_width,
486 size_->choice_width_units));
487 updateWidgetsFromLength(lyxview_->input_lyxwidth,
488 lyxview_->choice_width_lyxwidth, dummy, defaultUnit);
489 dummy = LyXLength(getLengthFromWidgets(size_->input_height,
490 size_->choice_width_units));
491 updateWidgetsFromLength(lyxview_->input_lyxheight,
492 lyxview_->choice_width_lyxheight, dummy, defaultUnit);
493 string const scale = getStringFromInput(size_->input_scale);
494 fl_set_input(lyxview_->input_lyxscale, scale.c_str());
497 } else if (!controller().bbChanged &&
498 (ob == bbox_->choice_bb_units ||
499 ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 ||
500 ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) {
501 controller().bbChanged = true;
502 } else if (ob == bbox_->button_getBB) {
503 string const filename = getStringFromInput(file_->input_filename);
504 if (!filename.empty()) {
505 string const fileWithAbsPath = MakeAbsPath(filename, OnlyPath(filename));
506 string bb = controller().readBB(fileWithAbsPath);
508 fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
509 fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
510 fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
511 fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
512 string const unit("pt");
513 fl_set_choice_text(bbox_->choice_bb_units, unit.c_str());
515 controller().bbChanged = false;
517 fl_set_input(bbox_->input_bb_x0, "");
518 fl_set_input(bbox_->input_bb_y0, "");
519 fl_set_input(bbox_->input_bb_x1, "");
520 fl_set_input(bbox_->input_bb_y1, "");
521 fl_set_choice_text(bbox_->choice_bb_units, "pt");
525 } else if (ob == size_->button_asis) {
526 setEnabled(size_->input_width, 0);
527 setEnabled(size_->choice_width_units, 0);
528 setEnabled(size_->input_height, 0);
529 setEnabled(size_->choice_height_units, 0);
530 setEnabled(size_->check_aspectratio, 0);
531 setEnabled(size_->input_scale, 0);
532 } else if (ob == size_->button_wh) {
533 setEnabled(size_->input_width, 1);
534 setEnabled(size_->choice_width_units, 1);
535 setEnabled(size_->input_height, 1);
536 setEnabled(size_->choice_height_units, 1);
537 setEnabled(size_->check_aspectratio, 1);
538 setEnabled(size_->input_scale, 0);
539 } else if (ob == size_->button_scale) {
540 setEnabled(size_->input_width, 0);
541 setEnabled(size_->choice_width_units, 0);
542 setEnabled(size_->input_height, 0);
543 setEnabled(size_->choice_height_units, 0);
544 setEnabled(size_->check_aspectratio, 0);
545 setEnabled(size_->input_scale, 1);
546 } else if (ob == size_->button_lyx_values) {
547 LyXLength dummy = LyXLength(getLengthFromWidgets(
548 lyxview_->input_lyxwidth, lyxview_->choice_width_lyxwidth));
549 updateWidgetsFromLength(size_->input_width,
550 size_->choice_width_units, dummy, defaultUnit);
551 dummy = LyXLength(getLengthFromWidgets(lyxview_->input_lyxheight,
552 lyxview_->choice_width_lyxheight));
553 updateWidgetsFromLength(size_->input_height,
554 size_->choice_height_units, dummy, defaultUnit);
555 string const scale = getStringFromInput(lyxview_->input_lyxscale);
556 fl_set_input(size_->input_scale, scale.c_str());
559 // check if the input is valid
560 bool invalid = !isValid(bbox_->input_bb_x0);
561 invalid = invalid || !isValid(bbox_->input_bb_x1);
562 invalid = invalid || !isValid(bbox_->input_bb_y0);
563 invalid = invalid || !isValid(bbox_->input_bb_y1);
564 invalid = invalid || !isValid(size_->input_width);
565 invalid = invalid || !isValid(size_->input_height);
566 invalid = invalid || !isValid(lyxview_->input_lyxwidth);
567 invalid = invalid || !isValid(lyxview_->input_lyxheight);
569 // deactivate OK/ Apply buttons and
570 // spit out warnings if invalid
571 if (ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_x1 ||
572 ob == bbox_->input_bb_y0 || ob == bbox_->input_bb_y1 ||
573 ob == size_->input_width || ob == size_->input_height ||
574 ob == lyxview_->input_lyxwidth || ob == lyxview_->input_lyxheight) {
576 fl_set_object_label(dialog_->text_warning,
577 _("Warning: Invalid Length!"));
578 fl_show_object(dialog_->text_warning);
579 return ButtonPolicy::SMI_INVALID;
581 fl_hide_object(dialog_->text_warning);
585 return ButtonPolicy::SMI_VALID;