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