From 6ca7a18ad9a098cc08182f1a9904ebc817b12611 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 26 Mar 2001 14:33:58 +0000 Subject: [PATCH] Implemented controller-view split for TabularCreate popup. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1827 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 4 +- .../controllers/ControlTabularCreate.C | 66 +++++++++++++++++++ .../controllers/ControlTabularCreate.h | 44 +++++++++++++ src/frontends/controllers/GUI.h | 16 +++++ src/frontends/controllers/Makefile.am | 2 + src/frontends/xforms/ChangeLog | 6 +- src/frontends/xforms/Dialogs.C | 6 +- src/frontends/xforms/FormTabularCreate.C | 52 +++------------ src/frontends/xforms/FormTabularCreate.h | 47 ++++--------- src/frontends/xforms/form_tabular_create.C | 6 +- src/frontends/xforms/form_tabular_create.h | 6 +- .../xforms/forms/form_tabular_create.fd | 12 ++-- src/frontends/xforms/forms/makefile | 4 +- 13 files changed, 178 insertions(+), 93 deletions(-) create mode 100644 src/frontends/controllers/ControlTabularCreate.C create mode 100644 src/frontends/controllers/ControlTabularCreate.h diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 94ffd17afc..9dc04f61f6 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -3,7 +3,9 @@ * ControlConnections.[Ch]: (docType): new method; returns the type of the buffer, LaTeX, Literate, LinuxDoc or DocBook. - * ControlRef.[Ch]: new files; controller for the Ref popup. + * ControlRef.[Ch]: + * ControlTabularCreate.[Ch]: new files; controller for the Ref and + TabularCreate popups, respectively. * GUI.h: * Makefile.am: associated changes. diff --git a/src/frontends/controllers/ControlTabularCreate.C b/src/frontends/controllers/ControlTabularCreate.C new file mode 100644 index 0000000000..1d2db58b01 --- /dev/null +++ b/src/frontends/controllers/ControlTabularCreate.C @@ -0,0 +1,66 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file ControlTabularCreate.C + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "ControlTabularCreate.h" +#include "BufferView.h" +#include "Dialogs.h" +#include "LyXView.h" +#include "lyxfunc.h" + +ControlTabularCreate::ControlTabularCreate(LyXView & lv, Dialogs & d) + : ControlDialog(lv, d) +{ + d_.showTabularCreate.connect(SigC::slot(this, + &ControlTabularCreate::show)); +} + + +string & ControlTabularCreate::params() const +{ + Assert(params_); + return *params_; +} + + +void ControlTabularCreate::setParams() +{ + if (params_) delete params_; + params_ = new string; + + bc().valid(); // so that the user can press Ok +} + + +void ControlTabularCreate::clearParams() +{ + if (params_) { + delete params_; + params_ = 0; + } +} + + +void ControlTabularCreate::apply() +{ + if (!lv_.view()->available()) + return; + + view().apply(); + + lv_.getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, params()); +} diff --git a/src/frontends/controllers/ControlTabularCreate.h b/src/frontends/controllers/ControlTabularCreate.h new file mode 100644 index 0000000000..b7b0e38267 --- /dev/null +++ b/src/frontends/controllers/ControlTabularCreate.h @@ -0,0 +1,44 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + *====================================================== + * + * \file ControlTabularCreate.h + */ + +#ifndef CONTROLTABULARCREATE_H +#define CONTROLTABULARCREATE_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ControlDialogs.h" + +/** A controller for the TabularCreate Dialog. + */ +class ControlTabularCreate : public ControlDialog { +public: + /// + ControlTabularCreate(LyXView &, Dialogs &); + /// + string & params() const; + +private: + /// Apply from dialog + virtual void apply(); + + /// set the params before show or update + virtual void setParams(); + /// clean-up on hide. + virtual void clearParams(); + + /// + string * params_; +}; + +#endif // CONTROLTABULARCREATE_H diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index 10ef6529bf..89442abd1b 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -165,6 +165,22 @@ public: }; +/** Specialization for TabularCreate dialog + */ +class ControlTabularCreate; + +template +class GUITabularCreate : + public GUI { +public: + /// + GUITabularCreate(LyXView & lv, Dialogs & d) + : GUI(lv, d) {} +}; + + /** Specialization for Url dialog */ class ControlUrl; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 853a71c3c6..96beb38d17 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -42,6 +42,8 @@ libcontrollers_la_SOURCES=\ ControlLog.h \ ControlRef.C \ ControlRef.h \ + ControlTabularCreate.C \ + ControlTabularCreate.h \ ControlUrl.C \ ControlUrl.h \ ControlVCLog.C \ diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 9947e2d20d..e0c925312f 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,7 +1,11 @@ 2001-03-26 Angus Leeming * FormRef.[Ch]: - * forms/form_ref.fd: implemented controller-view split. + * forms/form_ref.fd: + * FormTabularCreate.[Ch]: + * forms/form_tabular_create.fd: implemented controller-view split. + + * Dialogs.C: associated changes. 2001-03-23 Angus Leeming diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index b8b0cc80f4..fc5fa6cff6 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -30,6 +30,7 @@ #include "ControlLog.h" #include "ControlUrl.h" #include "ControlRef.h" +#include "ControlTabularCreate.h" #include "ControlVCLog.h" #include "GUI.h" @@ -45,6 +46,7 @@ #include "form_error.h" #include "form_include.h" #include "form_ref.h" +#include "form_tabular_create.h" #include "form_url.h" #include "FormBibitem.h" @@ -57,6 +59,7 @@ #include "FormInclude.h" #include "FormLog.h" #include "FormRef.h" +#include "FormTabularCreate.h" #include "FormUrl.h" #include "FormVCLog.h" @@ -72,7 +75,6 @@ #include "FormSearch.h" #include "FormSplash.h" #include "FormTabular.h" -#include "FormTabularCreate.h" #include "FormToc.h" #include "FormMinipage.h" @@ -96,6 +98,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIRef(*lv, *this)); add(new GUIUrl(*lv, *this)); add(new GUIVCLog(*lv, *this)); + add(new GUITabularCreate(*lv, *this)); add(new FormDocument(lv, this)); add(new FormExternal(lv, this)); @@ -109,7 +112,6 @@ Dialogs::Dialogs(LyXView * lv) add(new FormSearch(lv, this)); add(new FormSplash(lv, this)); add(new FormTabular(lv, this)); - add(new FormTabularCreate(lv, this)); add(new FormToc(lv, this)); add(new FormMinipage(lv, this)); diff --git a/src/frontends/xforms/FormTabularCreate.C b/src/frontends/xforms/FormTabularCreate.C index 2b8a0f57d2..8a0073c3c5 100644 --- a/src/frontends/xforms/FormTabularCreate.C +++ b/src/frontends/xforms/FormTabularCreate.C @@ -1,15 +1,13 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== - */ -/* FormTabularCreate.C - * FormTabularCreate Interface Class Implementation + * + * \file FormTabularCreate.C */ #include @@ -18,40 +16,17 @@ #pragma implementation #endif +#include "xformsBC.h" +#include "ControlTabularCreate.h" #include "FormTabularCreate.h" #include "form_tabular_create.h" -#include "buffer.h" -#include "BufferView.h" -#include "Dialogs.h" -#include "LyXView.h" -#include "insets/insettabular.h" #include "support/lstrings.h" -using SigC::slot; - -FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d) - : FormBaseBD(lv, d, _("Insert Tabular")) -{ - // let the dialog be shown - // This is a permanent connection so we won't bother - // storing a copy because we won't be disconnecting. - d->showTabularCreate.connect(slot(this, &FormTabularCreate::show)); -} - - -FL_FORM * FormTabularCreate::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - +typedef FormCB > base_class; -void FormTabularCreate::connect() -{ - bc().valid(true); - FormBaseBD::connect(); -} +FormTabularCreate::FormTabularCreate(ControlTabularCreate & c) + : base_class(c, _("Insert Tabular")) +{} void FormTabularCreate::build() @@ -78,12 +53,5 @@ void FormTabularCreate::apply() int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5); int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5); - string tmp = tostr(xsize) + " " + tostr(ysize); - lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp); -} - - -void FormTabularCreate::update() -{ - bc().readOnly(lv_->buffer()->isReadonly()); + controller().params() = tostr(xsize) + " " + tostr(ysize); } diff --git a/src/frontends/xforms/FormTabularCreate.h b/src/frontends/xforms/FormTabularCreate.h index 10191548ca..f966d4e1f3 100644 --- a/src/frontends/xforms/FormTabularCreate.h +++ b/src/frontends/xforms/FormTabularCreate.h @@ -1,66 +1,47 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team. + * Copyright 1995-2001 The LyX Team. * - *======================================================*/ -/* FormTabularCreate.h - * FormTabularCreate Interface Class + *====================================================== + * + * \file FormTabularCreate.h */ #ifndef FORMTABULARCREATE_H #define FORMTABULARCREATE_H -#include - #ifdef __GNUG__ #pragma interface #endif -#include "FormBaseDeprecated.h" +#include "FormBase.h" +class ControlTabularCreate; struct FD_form_tabular_create; -/** This class provides an XForms implementation of the FormTabularCreate +/** This class provides an XForms implementation of the TabularCreate Dialog. */ -class FormTabularCreate : public FormBaseBD { +class FormTabularCreate : + public FormCB > { public: - /// #FormTabularCreate x(LyXView ..., Dialogs ...);# - FormTabularCreate(LyXView *, Dialogs *); + /// + FormTabularCreate(ControlTabularCreate &); private: - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc(); - /// Connect signals etc. - virtual void connect(); - /// Apply from dialog virtual void apply(); - /// Update dialog before showing it - virtual void update(); - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; /// Build the dialog virtual void build(); + /// not needed + virtual void update() {}; /// FD_form_tabular_create * build_tabular_create(); - - /// Real GUI implementation. - boost::scoped_ptr dialog_; - /// The ButtonController - ButtonController bc_; }; - -inline -xformsBC & FormTabularCreate::bc() -{ - return bc_; -} -#endif +#endif // FORMTABULARCREATE diff --git a/src/frontends/xforms/form_tabular_create.C b/src/frontends/xforms/form_tabular_create.C index 1579272f6c..80d46292c0 100644 --- a/src/frontends/xforms/form_tabular_create.C +++ b/src/frontends/xforms/form_tabular_create.C @@ -27,21 +27,21 @@ FD_form_tabular_create * FormTabularCreate::build_tabular_create() obj = fl_add_box(FL_UP_BOX, 0, 0, 310, 130, ""); fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 10, 90, 90, 30, _("OK")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0); + fl_set_object_callback(obj, C_FormBaseOKCB, 0); { char const * const dummy = N_("Apply|#A"); fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 90, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0); + fl_set_object_callback(obj, C_FormBaseApplyCB, 0); { char const * const dummy = N_("Cancel|^["); fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 210, 90, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0); + fl_set_object_callback(obj, C_FormBaseCancelCB, 0); fdui->slider_columns = obj = fl_add_valslider(FL_HOR_SLIDER, 80, 50, 220, 30, _("Columns")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT); diff --git a/src/frontends/xforms/form_tabular_create.h b/src/frontends/xforms/form_tabular_create.h index ae2f48faef..677c9ac1f2 100644 --- a/src/frontends/xforms/form_tabular_create.h +++ b/src/frontends/xforms/form_tabular_create.h @@ -5,9 +5,9 @@ #define FD_form_tabular_create_h_ /** Callbacks, globals and object handlers **/ -extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); +extern "C" void C_FormBaseOKCB(FL_OBJECT *, long); +extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long); +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/frontends/xforms/forms/form_tabular_create.fd b/src/frontends/xforms/forms/form_tabular_create.fd index 63e2740a50..80a8eb2e44 100644 --- a/src/frontends/xforms/forms/form_tabular_create.fd +++ b/src/frontends/xforms/forms/form_tabular_create.fd @@ -46,8 +46,8 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ok -callback: C_FormBaseDeprecatedOKCB -argument: 0 +callback: C_FormBaseOKCB +argument: -------------------- class: FL_BUTTON @@ -64,8 +64,8 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_apply -callback: C_FormBaseDeprecatedApplyCB -argument: 0 +callback: C_FormBaseApplyCB +argument: -------------------- class: FL_BUTTON @@ -82,8 +82,8 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_cancel -callback: C_FormBaseDeprecatedCancelCB -argument: 0 +callback: C_FormBaseCancelCB +argument: -------------------- class: FL_VALSLIDER diff --git a/src/frontends/xforms/forms/makefile b/src/frontends/xforms/forms/makefile index 97442b0359..cfe8751157 100644 --- a/src/frontends/xforms/forms/makefile +++ b/src/frontends/xforms/forms/makefile @@ -36,6 +36,7 @@ SRCS := form_bibitem.fd \ form_maths_matrix.fd \ form_maths_panel.fd \ form_maths_space.fd \ + form_minipage.fd \ form_paragraph.fd \ form_preamble.fd \ form_preferences.fd \ @@ -46,8 +47,7 @@ SRCS := form_bibitem.fd \ form_tabular.fd \ form_tabular_create.fd \ form_toc.fd \ - form_url.fd \ - form_minipage.fd + form_url.fd OBJS := $(SRCS:.fd=.C) -- 2.39.2