]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormSplash.C
try this for distinguishing inner and outer tabs
[lyx.git] / src / frontends / xforms / FormSplash.C
1 /**
2  * \file FormSplash.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Allan Rae
7  * \author John Levon
8  */
9
10 #include <config.h>
11
12 #include FORMS_H_LOCATION
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "Dialogs.h"
19 #include "LyXView.h"
20 #include "form_splash.h"
21 #include "FormSplash.h"
22 #include "xform_helpers.h"
23 #include "version.h"
24 #include "support/filetools.h"
25 #include "lyxrc.h"
26
27 /* FIXME: Really, we shouldn't leave Splash hanging around, but I'm not sure
28  * how to make it self-destructive - jbl
29  */
30
31 extern "C" void C_FormSplashTimerCB(FL_OBJECT * ob, long)
32 {
33         FormSplash::CloseCB(ob);
34 }
35
36 extern "C" int C_FormSplashWMHideCB(FL_FORM * ob, void * d)
37 {
38         return FormBase::WMHideCB(ob, d);
39 }
40
41 FormSplash::FormSplash(LyXView * lv, Dialogs * d)
42         : FormBaseBI(lv, d, (string(_("LyX ")) + LYX_VERSION).c_str(), new IgnorantPolicy),
43           dialog_(0)
44 {
45         d->showSplash.connect(slot(this, &FormSplash::show));
46         d->hideSplash.connect(slot(this, &FormSplash::hide));
47 }
48
49
50 FormSplash::~FormSplash()
51 {
52         delete dialog_;
53 }
54
55
56 void FormSplash::CloseCB(FL_OBJECT * ob)
57 {
58         FormSplash * pre = static_cast<FormSplash*>(ob->form->u_vdata);
59         pre->hide();
60         delete pre->dialog_;
61         pre->dialog_ = 0;
62 }
63
64
65 void FormSplash::show()
66 {
67         if (!dialog_) {
68                 build();
69                 fl_set_form_atclose(dialog_->form, C_FormSplashWMHideCB, 0);
70         }
71
72         int const xpos = WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
73         int const ypos = HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
74
75         fl_set_form_position(dialog_->form, xpos, ypos);
76
77         // Show the title form at most 5 secs
78         fl_set_timer(dialog_->splash_timer, 5);
79
80         if (form()->visible)
81                 fl_raise_form(form());
82         else {
83                 connect();
84                 fl_show_form(dialog_->form, FL_PLACE_CENTER, FL_NOBORDER, title.c_str());
85         }
86 }
87
88
89 FL_FORM * FormSplash::form() const
90 {
91         if (dialog_)
92                 return dialog_->form;
93         return 0;
94 }
95
96
97 void FormSplash::build()
98 {
99         dialog_ = build_splash();
100
101         // Workaround dumb xforms sizing bug
102         minw_ = form()->w;
103         minh_ = form()->h;
104
105         string banner_file = LibFileSearch("images", "banner", "xpm");
106
107         if (lyxrc.show_banner && !banner_file.empty()) {
108                 fl_set_form_dblbuffer(dialog_->form, 1); // use dbl buffer
109                 fl_addto_form(dialog_->form);
110                 FL_OBJECT * obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
111                 fl_set_pixmapbutton_file(obj, banner_file.c_str());
112                 
113                 fl_set_pixmapbutton_focus_outline(obj, 3);
114                 fl_set_button_shortcut(obj, "^M ^[", 1);
115                 fl_set_object_boxtype(obj, FL_NO_BOX);
116                 fl_set_object_callback(obj, C_FormSplashTimerCB, 0);
117                 
118                 obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
119                 fl_set_object_lsize(obj, FL_NORMAL_SIZE);
120                 fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
121                 fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
122                 fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
123                 fl_set_object_lcol(obj, FL_FREE_COL3);
124                 fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
125                 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
126                 fl_end_form();
127         }
128 }