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