]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormSplash.C
Compile fixes for DEC cxx, John's maths and keymap patches.
[features.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 "version.h"
23 #include "support/filetools.h"
24 #include "lyxrc.h"
25
26 using SigC::slot;
27
28 extern "C" int C_FormSplashCloseCB(FL_FORM * forms, void *)
29 {
30         Assert(forms);
31         FormSplash * form = static_cast<FormSplash*>(forms->u_vdata);
32         form->hide();
33         return 0;
34 }
35
36
37 extern "C" void C_FormSplashCB(FL_OBJECT * ob, long)
38 {
39         FormSplash * form = static_cast<FormSplash*>(ob->form->u_vdata);
40         form->hide();
41 }
42
43  
44 FormSplash::FormSplash(LyXView *, Dialogs * d)
45         : d_(d)
46 {
47         c_ = d->showSplash.connect(slot(this, &FormSplash::show));
48 }
49
50
51 void FormSplash::show()
52 {
53         if (!lyxrc.show_banner)
54                 return;
55
56         if (!dialog_.get()) {
57                 build();
58                 fl_set_form_atclose(dialog_->form, C_FormSplashCloseCB, 0);
59         }
60
61         int const xpos = WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
62         int const ypos = HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
63
64         fl_set_form_position(dialog_->form, xpos, ypos);
65
66         // Show the title form at most 5 secs
67         fl_set_timer(dialog_->splash_timer, 5);
68
69         if (dialog_->form->visible)
70                 fl_raise_form(dialog_->form);
71         else
72                 fl_show_form(dialog_->form, FL_PLACE_CENTER, FL_NOBORDER, "");
73 }
74
75
76 void FormSplash::hide()
77 {
78         c_.disconnect();
79         if (dialog_->form && dialog_->form->visible)
80                 fl_hide_form(dialog_->form);
81         d_->destroySplash();
82 }
83
84  
85 void FormSplash::build()
86 {
87         string banner_file = LibFileSearch("images", "banner", "xpm");
88         if (banner_file.empty())
89                 return;
90  
91         dialog_.reset(build_splash());
92
93         // Workaround dumb xforms sizing bug
94         fl_set_form_minsize(dialog_->form, dialog_->form->w, dialog_->form->h);
95  
96         fl_set_form_dblbuffer(dialog_->form, 1); // use dbl buffer
97         fl_addto_form(dialog_->form);
98         FL_OBJECT * obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
99         fl_set_pixmapbutton_file(obj, banner_file.c_str());
100         
101         fl_set_pixmapbutton_focus_outline(obj, 3);
102         fl_set_button_shortcut(obj, "^M ^[", 1);
103         fl_set_object_boxtype(obj, FL_NO_BOX);
104         fl_set_object_callback(obj, C_FormSplashCB, 0);
105         
106         obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
107         fl_set_object_lsize(obj, FL_NORMAL_SIZE);
108         fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
109         fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
110         fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
111         fl_set_object_lcol(obj, FL_FREE_COL3);
112         fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
113         fl_set_object_lstyle(obj, FL_BOLD_STYLE);
114         fl_end_form();
115 }