]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
update patch 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 #include "support/LAssert.h"
23
24
25 FormError::FormError(LyXView * lv, Dialogs * d)
26         : FormInset( lv, d, _("LaTeX Error"), new OkCancelPolicy),
27           dialog_(0), 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 FormError::~FormError()
38 {
39         delete dialog_;
40 }
41
42
43 FL_FORM * FormError::form() const
44 {
45         if (dialog_) return dialog_->form;
46         return 0;
47 }
48
49
50 void FormError::disconnect()
51 {
52         inset_ = 0;
53         message_.erase();
54         FormInset::disconnect();
55 }
56
57
58 void FormError::showInset(InsetError * inset)
59 {
60         if (inset == 0) return; // Is this _really_ allowed? (Lgb)
61
62         // If connected to another inset, disconnect from it.
63         if (inset_)
64                 ih_.disconnect();
65
66         inset_ = inset;
67         message_ = inset->getContents();
68         ih_ = inset->hide.connect(slot(this, &FormError::hide));
69         show();
70 }
71
72
73 void FormError::update()
74 {
75         fl_set_object_label(dialog_->message, message_.c_str());
76 }
77
78
79 void FormError::build()
80 {
81         dialog_ = build_error();
82
83         // Workaround dumb xforms sizing bug
84         minw_ = form()->w;
85         minh_ = form()->h;
86         
87         // Manage the cancel/close button
88         bc_.setCancel(dialog_->button_cancel);
89         bc_.refresh();
90 }