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