Implemented controller-view split for Splash screen.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1836 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-03-27 13:00:41 +00:00
parent cdb40c285b
commit d553558b19
10 changed files with 221 additions and 56 deletions

View File

@ -1,6 +1,11 @@
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
* ControlPrint.[Ch]: new file; controller for the Print popups.
* ControlPrint.[Ch]:
* ControlSplash.[Ch]: new files; controller for the Print popup and
Splash screen respectively.
* ViewBase.h (ViewSplash): new base class for GUI-specific Splash
screens.
* GUI.h:
* Makefile.am: associated changes.

View File

@ -0,0 +1,63 @@
/**
* \file ControlSplash.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author Allan Rae
* \author John Levon
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlSplash.h"
#include "Dialogs.h"
#include "ViewBase.h"
#include "version.h"
#include "support/filetools.h"
#include "lyxrc.h" // show_banner
ControlSplash::ControlSplash(Dialogs & d)
: d_(d)
{
c_ = d.showSplash.connect(SigC::slot(this, &ControlSplash::show));
}
string const & ControlSplash::bannerFile() const
{
return banner_file_;
}
string const & ControlSplash::LyXVersion() const
{
return version_;
}
void ControlSplash::show()
{
if (!lyxrc.show_banner)
return;
banner_file_ = LibFileSearch("images", "banner", "xpm");
if (banner_file_.empty())
return;
version_ = LYX_VERSION;
view().show();
}
void ControlSplash::hide()
{
view().hide();
c_.disconnect();
d_.destroySplash();
}

View File

@ -0,0 +1,57 @@
/**
* \file ControlSplash.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author Allan Rae
* \author John Levon
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#ifndef CONTROLSPLASH_H
#define CONTROLSPLASH_H
#ifdef __GNUG__
#pragma interface
#endif
#include "DialogBase.h"
#include "LString.h"
class Dialogs;
class ViewSplash;
/** The startup splash screen
*/
class ControlSplash : public DialogBase {
public:
///
ControlSplash(Dialogs &);
///
string const & bannerFile() const;
///
string const & LyXVersion() const;
/// hide (and destroy) the dialog
void hide();
private:
/** Allow the Controller to access the View. This method must be
instantiated in a daughter class that creates the actual instance
of the View. */
virtual ViewSplash & view() = 0;
/// show the dialog
void show();
/// our container
Dialogs & d_;
/// the show connection
SigC::Connection c_;
///
string banner_file_;
///
string version_;
};
#endif // CONTROLSPLASH_H

View File

@ -9,6 +9,23 @@
#ifndef GUI_H
#define GUI_H
/** This class instantiates and makes available the GUI-specific
View for the Splash screen controller.
*/
template <class GUIview>
class GUISplash : public ControlSplash {
public:
///
GUISplash(Dialogs & d) : ControlSplash(d), view_(*this) {}
///
virtual ViewSplash & view() { return view_; }
private:
///
GUIview view_;
};
/** This class instantiates and makes available the GUI-specific
ButtonController and View.
*/

View File

@ -46,6 +46,8 @@ libcontrollers_la_SOURCES=\
ControlRef.h \
ControlSearch.C \
ControlSearch.h \
ControlSplash.C \
ControlSplash.h \
ControlTabularCreate.C \
ControlTabularCreate.h \
ControlUrl.C \

View File

@ -16,6 +16,7 @@
#include <boost/utility.hpp>
#include "ControlBase.h"
#include "ControlSplash.h"
class ViewBase {
public:
@ -53,6 +54,30 @@ protected:
};
class ViewSplash {
public:
///
ViewSplash(ControlSplash & c) : controller_(c) {}
///
virtual ~ViewSplash() {}
/// Hide the dialog.
virtual void hide() = 0;
/// Create the dialog and show it.
virtual void show() = 0;
/** The shortcut allows (e.g. xform's) global callback functions
access without making the whole controller_ public.
*/
///
void Hide() { controller_.hide(); }
protected:
/// The view is, after all, controlled!
ControlSplash & controller_;
};
/** A generic class to cast the ButtonController controller_.bc_ to it's
daughter class. */
template <class GUIbc>

View File

@ -1,7 +1,8 @@
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
* FormPrint.[Ch]:
* forms/form_print.fd: implemented controller-view split.
* forms/form_print.fd:
* FormSplash.[Ch]: implemented controller-view split.
* Dialogs.C: associated changes.

View File

@ -31,6 +31,7 @@
#include "ControlPrint.h"
#include "ControlRef.h"
#include "ControlSearch.h"
#include "ControlSplash.h"
#include "ControlTabularCreate.h"
#include "ControlUrl.h"
#include "ControlVCLog.h"
@ -50,6 +51,7 @@
#include "form_print.h"
#include "form_ref.h"
#include "form_search.h"
#include "form_splash.h"
#include "form_tabular_create.h"
#include "form_url.h"
@ -65,6 +67,7 @@
#include "FormPrint.h"
#include "FormRef.h"
#include "FormSearch.h"
#include "FormSplash.h"
#include "FormTabularCreate.h"
#include "FormUrl.h"
#include "FormVCLog.h"
@ -77,7 +80,6 @@
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormSplash.h"
#include "FormTabular.h"
#include "FormToc.h"
#include "FormMinipage.h"
@ -88,7 +90,7 @@ SigC::Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv)
{
splash_.reset(new FormSplash(lv, this));
splash_.reset(new GUISplash<FormSplash>(*this));
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
@ -114,7 +116,6 @@ Dialogs::Dialogs(LyXView * lv)
add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this));
add(new FormSplash(lv, this));
add(new FormTabular(lv, this));
add(new FormToc(lv, this));
add(new FormMinipage(lv, this));

View File

@ -10,56 +10,57 @@
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include "LyXView.h"
#include "form_splash.h"
#include "ControlSplash.h"
#include "FormSplash.h"
#include "version.h"
#include "support/filetools.h"
#include "lyxrc.h"
#include "form_splash.h"
#include "form_splash.h"
#include "support/LAssert.h"
using SigC::slot;
extern "C" int C_FormSplashCloseCB(FL_FORM * forms, void *)
extern "C" int C_FormSplashCloseCB(FL_FORM * form, void *)
{
Assert(forms);
FormSplash * form = static_cast<FormSplash*>(forms->u_vdata);
form->hide();
return 0;
Assert(form && form->u_vdata);
FormSplash * pre = static_cast<FormSplash *>(form->u_vdata);
pre->Hide();
return FL_CANCEL;
}
extern "C" void C_FormSplashCB(FL_OBJECT * ob, long)
{
FormSplash * form = static_cast<FormSplash*>(ob->form->u_vdata);
form->hide();
Assert(ob && ob->form && ob->form->u_vdata);
FormSplash * pre = static_cast<FormSplash*>(ob->form->u_vdata);
pre->Hide();
}
FormSplash::FormSplash(LyXView *, Dialogs * d)
: d_(d)
FormSplash::FormSplash(ControlSplash & c)
: ViewSplash(c)
{}
ControlSplash & FormSplash::controller() const
{
c_ = d->showSplash.connect(slot(this, &FormSplash::show));
return static_cast<ControlSplash &>(controller_);
//return dynamic_cast<ControlSplash &>(controller_);
}
void FormSplash::show()
{
if (!lyxrc.show_banner)
return;
if (!dialog_.get()) {
build();
fl_set_form_atclose(dialog_->form, C_FormSplashCloseCB, 0);
}
int const xpos = WidthOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
int const ypos = HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen));
int const xpos = WidthOfScreen(ScreenOfDisplay(fl_get_display(),
fl_screen));
int const ypos = HeightOfScreen(ScreenOfDisplay(fl_get_display(),
fl_screen));
fl_set_form_position(dialog_->form, xpos, ypos);
@ -69,41 +70,37 @@ void FormSplash::show()
if (dialog_->form->visible)
fl_raise_form(dialog_->form);
else
// Workaround dumb xforms sizing bug
fl_set_form_minsize(dialog_->form,
dialog_->form->w,
dialog_->form->h);
fl_show_form(dialog_->form, FL_PLACE_CENTER, FL_NOBORDER, "");
}
void FormSplash::hide()
{
c_.disconnect();
if (dialog_->form && dialog_->form->visible)
fl_hide_form(dialog_->form);
d_->destroySplash();
}
void FormSplash::build()
{
string banner_file = LibFileSearch("images", "banner", "xpm");
if (banner_file.empty())
return;
dialog_.reset(build_splash());
// Workaround dumb xforms sizing bug
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_file(obj, controller().bannerFile().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);
obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16,
controller().LyXVersion().c_str());
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);

View File

@ -16,37 +16,34 @@
#pragma interface
#endif
#include "DialogBase.h"
#include "xformsBC.h"
#include "ViewBase.h"
class ControlSplash;
struct FD_form_splash;
class Dialogs;
class LyXView;
/** The startup splash screen
*/
class FormSplash : public DialogBase {
class FormSplash : public ViewSplash {
public:
///
FormSplash(LyXView *, Dialogs *);
FormSplash(ControlSplash &);
/// hide (and destroy) the dialog
void hide();
private:
/// show the dialog
void show();
/// Build the dialog
void build();
/// hide the dialog
void hide();
/// show the dialog
void show();
/// The parent controller
ControlSplash & controller() const;
/// Fdesign generated method
FD_form_splash * build_splash();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_splash> dialog_;
/// our container
Dialogs * d_;
/// the show connection
SigC::Connection c_;
};
#endif // FORMSPLASH_H