]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
Fix xforms menus display problems
[lyx.git] / src / frontends / xforms / FormError.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "Dialogs.h"
19 #include "FormError.h"
20 #include "form_error.h"
21
22 static int minh, minw;
23
24 FormError::FormError(LyXView * lv, Dialogs * d)
25         : FormBase(lv, d, _("LaTeX Error")),
26           dialog_(0), ih_(0), message_("")
27 {
28         // let the dialog be shown
29         // This is a permanent connection so we won't bother
30         // storing a copy because we won't be disconnecting.
31         d->showError.connect(slot(this, &FormError::showInset));
32 }
33
34
35 FormError::~FormError()
36 {
37         delete dialog_;
38 }
39
40
41 void FormError::showInset( InsetError * const inset )
42 {
43         if( dialogIsOpen || inset == 0 ) return;
44
45         ih_ = inset->hide.connect(slot(this, &FormError::hide));
46
47         message_ = inset->getContents();
48         show();
49 }
50
51
52 void FormError::update()
53 {
54         fl_set_form_minsize(form(), minw, minh);
55         fl_set_object_label(dialog_->message, message_.c_str());
56 }
57
58
59 void FormError::build()
60 {
61         dialog_ = build_error();
62
63         // XFORMS bug workaround
64         // Define the min/max dimensions. Actually applied in update()
65         minw = form()->w; minh = form()->h;
66 }
67
68
69 void FormError::clearStore()
70 {
71         ih_.disconnect();
72         message_.empty();
73 }
74
75
76 FL_FORM * const FormError::form() const
77 {
78         if( dialog_ ) // no need to test for dialog_->form
79                 return dialog_->form;
80         else
81                 return 0;
82 }