2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995-2000 The LyX Team.
8 * =================================================
22 #include <sigc++/signal_system.h>
23 #include "gnome_helpers.h"
35 * This is a base class for Gnome dialogs. Basically it handles all the common
36 * work that is needed for all dialogs.
38 class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
41 GnomeBase(ControlBase & c, string const & glade_file, string const & name);
47 T* getWidget(char const * name) const;
50 /// Loads the glade file to memory.
53 /// The glade file name
57 /// The XML representation of the dialogs.
58 mutable GladeXML * xml_;
63 T* GnomeBase::getWidget(char const * name) const
67 return getWidgetPtr<T>(xml_, name);
71 * This class is used to provide a simple automatic casting of the controller.
72 * We chose not to make GnomeBase a template since it has some size and we
73 * have no reason to duplicate it by making it a template.
75 * Basically the FormCB<Controller> template instantiates GnomeBase and passes
76 * the parameters to it and it also adds the controller() method to give us
77 * a reference to the controller of the correct type (the type is set by the
78 * template parameter).
80 template <class Controller>
81 class FormCB : public GnomeBase {
83 FormCB(Controller & c, string const & file, string const & name);
86 Controller & controller();
89 template <class Controller>
90 FormCB<Controller>::FormCB(Controller & c, string const & file, string const & name)
91 : GnomeBase(c, file, name)
94 template <class Controller>
96 FormCB<Controller>::controller()
98 return static_cast<Controller &>(controller_);