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