From: Angus Leeming Date: Mon, 12 Mar 2001 12:44:56 +0000 (+0000) Subject: John's splash patch X-Git-Tag: 1.6.10~21479 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1df761e26d807aeb97413e54f23aeefe716f58e1;p=features.git John's splash patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1740 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 6e79fd1811..617abc67fb 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -349,7 +349,8 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->setState(); AllowInput(bv_); - owner_->getDialogs()->hideSplash(); + /// get rid of the splash screen if it's not gone already + owner_->getDialogs()->destroySplash(); return 0; } diff --git a/src/ChangeLog b/src/ChangeLog index a91ace0bbf..bb6990cc29 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -3,6 +3,10 @@ * lyx.C: * lyx.h: strip external form +2001-03-12 John Levon + + * BufferView_pimpl.C: add comment, destroySplash() + 2001-03-12 Lars Gullik Bjønnes * buffer.C: add using std::stringstream. diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index f7420413f5..8bbea3192f 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -2,6 +2,12 @@ * Dialogs.h: add showExternal signal +2001-03-12 John Levon + + * Dialogs.h: add pointer to splash form + + * GUIRunTime.h: minor cleanup + 2001-02-26 John Levon * Makefile.am diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index dec8d1e207..2ac0c02acd 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -29,6 +29,8 @@ class DialogBase; // Maybe this should be a UIFunc modelled on LyXFunc class LyXView; +class FormSplash; + class InsetGraphics; class InsetBibKey; class InsetBibtex; @@ -139,8 +141,8 @@ public: Signal0 showSearch; /// pop up the splash Signal0 showSplash; - /// hide the splash immediately - Signal0 hideSplash; + /// destroy the splash dialog + void destroySplash(); /// Signal1 showTabular; /// @@ -159,8 +161,10 @@ public: Signal0 updateCharacter; // allow update as cursor moves //@} private: - /// + /// the dialogs being managed std::vector dialogs_; + /// the splash dialog + FormSplash * splash_; }; #endif diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 7b4a8e594d..90a7960893 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -15,20 +15,19 @@ #pragma interface #endif -class LyXView; - /** The LyX GUI independent guiruntime class The GUI interface is implemented in the corresponding frontends GUIRunTime.C file. */ class GUIRunTime { public: + /// initialise the toolkit static int initApplication(int argc, char * argv[]); - /// + /// process pending events static void processEvents(); - /// + /// enter the permanent event loop until "finished" becomes false static void runTime(); /// This is run first in the LyXGUI constructor. diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index c3d6c8c39d..49eb7e342f 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -9,6 +9,18 @@ * xforms/forms/makefile: * forms/form_external.fd: add FormExternal +2001-03-12 John Levon + + * Dialogs.C: add destroySplash() + + * form_splash.h: + * form_splash.C: + * forms/form_splash.fd: + * FormSplash.h: + * FormSplash.C: make independent of FormBase, tidy + + * Menubar_pimpl.C: destroy splash on interaction + 2001-03-12 Lars Gullik Bjønnes * FormToc.h: use Buffer::typedef diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 7aa1eb1197..604c032129 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -51,6 +51,8 @@ Signal0 Dialogs::redrawGUI; Dialogs::Dialogs(LyXView * lv) { + splash_ = new FormSplash(lv, this); + dialogs_.push_back(new FormBibitem(lv, this)); dialogs_.push_back(new FormBibtex(lv, this)); dialogs_.push_back(new FormCharacter(lv, this)); @@ -70,7 +72,6 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormPrint(lv, this)); dialogs_.push_back(new FormRef(lv, this)); dialogs_.push_back(new FormSearch(lv, this)); - dialogs_.push_back(new FormSplash(lv, this)); dialogs_.push_back(new FormTabular(lv, this)); dialogs_.push_back(new FormTabularCreate(lv, this)); dialogs_.push_back(new FormToc(lv, this)); @@ -90,9 +91,17 @@ Dialogs::~Dialogs() ++iter) { delete *iter; } + delete splash_; } +void Dialogs::destroySplash() +{ + delete splash_; + splash_ = 0; +} + + /***************************************************************************** Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors? diff --git a/src/frontends/xforms/FormSplash.C b/src/frontends/xforms/FormSplash.C index e99305a92d..2316751d00 100644 --- a/src/frontends/xforms/FormSplash.C +++ b/src/frontends/xforms/FormSplash.C @@ -10,7 +10,7 @@ #include #include FORMS_H_LOCATION - + #ifdef __GNUG__ #pragma implementation #endif @@ -19,54 +19,46 @@ #include "LyXView.h" #include "form_splash.h" #include "FormSplash.h" -#include "xforms_helpers.h" #include "version.h" #include "support/filetools.h" #include "lyxrc.h" -/* FIXME: Really, we shouldn't leave Splash hanging around, but I'm not sure - * how to make it self-destructive - jbl - */ - -extern "C" void C_FormSplashTimerCB(FL_OBJECT * ob, long) + +extern "C" int C_FormSplashCloseCB(FL_FORM * forms, void *) { - FormSplash::CloseCB(ob); + Assert(forms); + FormSplash * form = static_cast(forms->u_vdata); + form->hide(); + return 0; } -extern "C" int C_FormSplashWMHideCB(FL_FORM * ob, void * d) + +extern "C" void C_FormSplashCB(FL_OBJECT * ob, long) { - return FormBase::WMHideCB(ob, d); + FormSplash * form = static_cast(ob->form->u_vdata); + form->hide(); } - -FormSplash::FormSplash(LyXView * lv, Dialogs * d) - : FormBaseBI(lv, d, (string(_("LyX ")) + LYX_VERSION).c_str(), new IgnorantPolicy), - dialog_(0) + + +FormSplash::FormSplash(LyXView *, Dialogs * d) + : dialog_(0), d_(d) { - d->showSplash.connect(slot(this, &FormSplash::show)); - d->hideSplash.connect(slot(this, &FormSplash::hide)); + c_ = d->showSplash.connect(slot(this, &FormSplash::show)); } FormSplash::~FormSplash() { + c_.disconnect(); delete dialog_; } -void FormSplash::CloseCB(FL_OBJECT * ob) -{ - FormSplash * pre = static_cast(ob->form->u_vdata); - pre->hide(); - delete pre->dialog_; - pre->dialog_ = 0; -} - - void FormSplash::show() { if (!dialog_) { build(); - fl_set_form_atclose(dialog_->form, C_FormSplashWMHideCB, 0); + fl_set_form_atclose(dialog_->form, C_FormSplashCloseCB, 0); } int const xpos = WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)); @@ -77,52 +69,51 @@ void FormSplash::show() // Show the title form at most 5 secs fl_set_timer(dialog_->splash_timer, 5); - if (form()->visible) - fl_raise_form(form()); - else { - connect(); - fl_show_form(dialog_->form, FL_PLACE_CENTER, FL_NOBORDER, title.c_str()); - } + if (dialog_->form->visible) + fl_raise_form(dialog_->form); + else + fl_show_form(dialog_->form, FL_PLACE_CENTER, FL_NOBORDER, ""); } -FL_FORM * FormSplash::form() const +void FormSplash::hide() { - if (dialog_) - return dialog_->form; - return 0; + d_->destroySplash(); } - + void FormSplash::build() { + if (!lyxrc.show_banner) + return; + + string banner_file = LibFileSearch("images", "banner", "xpm"); + + if (banner_file.empty()) + return; + dialog_ = build_splash(); // Workaround dumb xforms sizing bug - minw_ = form()->w; - minh_ = form()->h; - - string banner_file = LibFileSearch("images", "banner", "xpm"); - - if (lyxrc.show_banner && !banner_file.empty()) { - fl_set_form_dblbuffer(dialog_->form, 1); // use dbl buffer - fl_addto_form(dialog_->form); - FL_OBJECT * obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, ""); - fl_set_pixmapbutton_file(obj, banner_file.c_str()); - - fl_set_pixmapbutton_focus_outline(obj, 3); - fl_set_button_shortcut(obj, "^M ^[", 1); - fl_set_object_boxtype(obj, FL_NO_BOX); - fl_set_object_callback(obj, C_FormSplashTimerCB, 0); - - obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c); - fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b); - fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2); - fl_set_object_lcol(obj, FL_FREE_COL3); - fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE); - fl_set_object_lstyle(obj, FL_BOLD_STYLE); - fl_end_form(); - } + fl_set_form_minsize(dialog_->form, dialog_->form->w, dialog_->form->h); + + fl_set_form_dblbuffer(dialog_->form, 1); // use dbl buffer + fl_addto_form(dialog_->form); + FL_OBJECT * obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, ""); + fl_set_pixmapbutton_file(obj, banner_file.c_str()); + + fl_set_pixmapbutton_focus_outline(obj, 3); + fl_set_button_shortcut(obj, "^M ^[", 1); + fl_set_object_boxtype(obj, FL_NO_BOX); + fl_set_object_callback(obj, C_FormSplashCB, 0); + + obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c); + fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b); + fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2); + fl_set_object_lcol(obj, FL_FREE_COL3); + fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE); + fl_set_object_lstyle(obj, FL_BOLD_STYLE); + fl_end_form(); } diff --git a/src/frontends/xforms/FormSplash.h b/src/frontends/xforms/FormSplash.h index 90acad8139..ab868f90f1 100644 --- a/src/frontends/xforms/FormSplash.h +++ b/src/frontends/xforms/FormSplash.h @@ -10,37 +10,41 @@ #ifndef FORMSPLASH_H #define FORMSPLASH_H -#include "FormBase.h" - #ifdef __GNUG__ #pragma interface #endif +#include "DialogBase.h" + struct FD_form_splash; +class Dialogs; +class LyXView; /** The startup splash screen */ -class FormSplash : public FormBaseBI { +class FormSplash : public DialogBase { public: FormSplash(LyXView *, Dialogs *); ~FormSplash(); - /// close the dialog - static void CloseCB(FL_OBJECT *); + /// hide (and destroy) the dialog + void hide(); private: /// show the dialog - virtual void show(); + void show(); /// Build the dialog - virtual void build(); - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; + void build(); /// Fdesign generated method FD_form_splash * build_splash(); /// Real GUI implementation. FD_form_splash * dialog_; + /// our container + Dialogs * d_; + /// the show connection + Connection c_; }; #endif // FORMSPLASH_H diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index f1a66d1d35..ef5c8fae78 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -21,6 +21,7 @@ #include "lyxfunc.h" #include "kbmap.h" #include "buffer.h" +#include "Dialogs.h" #include "LyXView.h" #include "MenuBackend.h" #include "Menubar_pimpl.h" @@ -577,6 +578,12 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button) LyXView * view = iteminfo->pimpl_->owner_; MenuItem const * item = iteminfo->item_.get(); + /* get the splash out of the way. It would be nicer + * to only have this code at the start, but xforms + * makes it too ugly to do + */ + view->getDialogs()->destroySplash(); + if (button == 1) { // set the pseudo menu-button fl_set_object_boxtype(ob, FL_DOWN_BOX); diff --git a/src/frontends/xforms/form_splash.C b/src/frontends/xforms/form_splash.C index c4d0e61f66..d2e3418f11 100644 --- a/src/frontends/xforms/form_splash.C +++ b/src/frontends/xforms/form_splash.C @@ -27,7 +27,7 @@ FD_form_splash * FormSplash::build_splash() obj = fl_add_box(FL_UP_BOX, 0, 0, 420, 290, ""); fl_set_object_color(obj, FL_BLACK, FL_TOP_BCOL); fdui->splash_timer = obj = fl_add_timer(FL_HIDDEN_TIMER, 110, 170, 190, 60, ""); - fl_set_object_callback(obj, C_FormSplashTimerCB, 0); + fl_set_object_callback(obj, C_FormSplashCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_splash.h b/src/frontends/xforms/form_splash.h index 68b6df568a..af25924e7d 100644 --- a/src/frontends/xforms/form_splash.h +++ b/src/frontends/xforms/form_splash.h @@ -5,7 +5,7 @@ #define FD_form_splash_h_ /** Callbacks, globals and object handlers **/ -extern "C" void C_FormSplashTimerCB(FL_OBJECT *, long); +extern "C" void C_FormSplashCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/frontends/xforms/forms/form_splash.fd b/src/frontends/xforms/forms/form_splash.fd index d746fbda4d..b6f02a9378 100644 --- a/src/frontends/xforms/forms/form_splash.fd +++ b/src/frontends/xforms/forms/form_splash.fd @@ -45,7 +45,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: splash_timer -callback: C_FormSplashTimerCB +callback: C_FormSplashCB argument: 0 ==============================