]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormCopyright.C
more FILMagain stuff
[lyx.git] / src / frontends / xforms / FormCopyright.C
1 /* FormCopyright.C
2  * FormCopyright Interface Class Implementation
3  */
4
5 #include <config.h>
6 #include "lyx_gui_misc.h"
7 #include "gettext.h"
8 #include FORMS_H_LOCATION
9
10 #include "xform_macros.h"
11 #include "FormCopyright.h"
12 #include "Dialogs.h"
13 #include "LyXView.h"
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 C_RETURNCB(FormCopyright, WMHideCB)
20 C_GENERICCB(FormCopyright, OKCB)
21
22 FormCopyright::FormCopyright(LyXView * lv, Dialogs * d)
23         : dialog_(0), lv_(lv), d_(d), h_(0)
24 {
25         // let the dialog be shown
26         // This is a permanent connection so we won't bother
27         // storing a copy because we won't be disconnecting.
28         d->showCopyright.connect(slot(this, &FormCopyright::show));
29 }
30
31
32 FormCopyright::~FormCopyright()
33 {
34         free();
35 }
36
37
38 void FormCopyright::build()
39 {
40   dialog_ = build_copyright();
41 }
42
43
44 void FormCopyright::show()
45 {
46         if (!dialog_) {
47                 build();
48                 fl_set_form_atclose(dialog_->form_copyright,
49                                     C_FormCopyrightWMHideCB, 0);
50         }
51
52         if (dialog_->form_copyright->visible) {
53                 fl_raise_form(dialog_->form_copyright);
54         } else {
55                 fl_show_form(dialog_->form_copyright,
56                              FL_PLACE_MOUSE,
57                              FL_FULLBORDER,
58                              _("Copyright and Warranty"));
59                 h_ = d_->hideAll.connect(slot(this, &FormCopyright::hide));
60         }
61 }
62
63
64 void FormCopyright::hide()
65 {
66         if (dialog_
67             && dialog_->form_copyright
68             && dialog_->form_copyright->visible) {
69                 fl_hide_form(dialog_->form_copyright);
70                 h_.disconnect();
71         }
72         free();
73 }
74
75
76 void FormCopyright::free()
77 {
78         // we don't need to delete h here because
79         // hide() does that after disconnecting.
80         if (dialog_) {
81                 if (dialog_->form_copyright
82                     && dialog_->form_copyright->visible) {
83                         hide();
84                 }
85                 fl_free_form(dialog_->form_copyright);
86                 delete dialog_;
87                 dialog_ = 0;
88         }
89 }
90
91
92 int FormCopyright::WMHideCB(FL_FORM * form, void *)
93 {
94         // Ensure that the signal h is disconnected even if the
95         // window manager is used to close the dialog.
96         FormCopyright * pre = static_cast<FormCopyright*>(form->u_vdata);
97         pre->hide();
98         return FL_CANCEL;
99 }
100
101
102 void FormCopyright::OKCB(FL_OBJECT * ob, long)
103 {
104         FormCopyright * pre = static_cast<FormCopyright*>(ob->form->u_vdata);
105         pre->hide();
106 }