]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
Merging BRANCH_MVC back into HEAD.
[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 #include "insets/inseterror.h"
22 #include "support/LAssert.h"
23
24
25 FormError::FormError(LyXView * lv, Dialogs * d)
26         : FormInset( lv, d, _("LaTeX Error")),
27           inset_(0)
28 {
29         Assert(lv && d);
30         // let the dialog be shown
31         // This is a permanent connection so we won't bother
32         // storing a copy because we won't be disconnecting.
33         d->showError.connect(slot(this, &FormError::showInset));
34 }
35
36
37 FL_FORM * FormError::form() const
38 {
39         if (dialog_.get()) return dialog_->form;
40         return 0;
41 }
42
43
44 void FormError::disconnect()
45 {
46         inset_ = 0;
47         message_.erase();
48         FormInset::disconnect();
49 }
50
51
52 void FormError::showInset(InsetError * inset)
53 {
54         if (inset == 0) return; // Is this _really_ allowed? (Lgb)
55
56         // If connected to another inset, disconnect from it.
57         if (inset_)
58                 ih_.disconnect();
59
60         inset_ = inset;
61         message_ = inset->getContents();
62         ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
63         show();
64 }
65
66
67 void FormError::update()
68 {
69         fl_set_object_label(dialog_->message, message_.c_str());
70 }
71
72
73 void FormError::build()
74 {
75         dialog_.reset(build_error());
76
77         // Workaround dumb xforms sizing bug
78         minw_ = form()->w;
79         minh_ = form()->h;
80         
81         // Manage the cancel/close button
82         bc().setCancel(dialog_->button_cancel);
83         bc().refresh();
84 }