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