]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
9bdf9dfb69b3977bcb717bf8831f433ebca3b912
[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), message_("")
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_.empty();
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         show();
66 }
67
68
69 void FormError::update(bool switched)
70 {
71         if (switched) {
72                 hide();
73                 return;
74         }
75
76         fl_set_object_label(dialog_->message, message_.c_str());
77 }
78
79
80 void FormError::build()
81 {
82         dialog_ = build_error();
83
84         // Workaround dumb xforms sizing bug
85         minw_ = form()->w;
86         minh_ = form()->h;
87 }