]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
allow derived classes to manipulate signal connections
[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         : FormBase( lv, d, BUFFER_DEPENDENT, _("LaTeX Error") ),
27           dialog_(0), ih_(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 void FormError::showInset( InsetError * const inset )
43 {
44         if( dialogIsOpen || inset == 0 ) return;
45
46         ih_ = inset->hide.connect(slot(this, &FormError::hide));
47
48         message_ = inset->getContents();
49         show();
50 }
51
52
53 void FormError::update()
54 {
55         fl_set_form_minsize(form(), minw, minh);
56         fl_set_object_label(dialog_->message, message_.c_str());
57 }
58
59
60 void FormError::build()
61 {
62         dialog_ = build_error();
63
64         // XFORMS bug workaround
65         // Define the min/max dimensions. Actually applied in update()
66         minw = form()->w; minh = form()->h;
67 }
68
69
70 void FormError::clearStore()
71 {
72         ih_.disconnect();
73         message_.empty();
74 }
75
76
77 FL_FORM * const FormError::form() const
78 {
79         if( dialog_ ) // no need to test for dialog_->form
80                 return dialog_->form;
81         else
82                 return 0;
83 }