]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormTabularCreate.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / FormTabularCreate.C
index 3789fb21affe2dc1846db5c1dbac763768eb7fb9..384aefd1f61d63f41b297c37bf97b61d32b0fcb3 100644 (file)
@@ -1,91 +1,57 @@
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
+/**
+ * \file FormTabularCreate.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Jürgen Vigna
  *
- *           Copyright 2000 The LyX Team.
- *
- * ======================================================
- */
-/* FormTabularCreate.C
- * FormTabularCreate Interface Class Implementation
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
+#include <utility>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
+#include "xformsBC.h"
+#include "ControlTabularCreate.h"
 #include "FormTabularCreate.h"
-#include "form_tabular_create.h"
-#include "BufferView.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "insets/insettabular.h"
+#include "forms/form_tabular_create.h"
+#include "Tooltips.h"
+#include "support/lstrings.h"
+#include FORMS_H_LOCATION
 
-FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
-       : FormBaseBD(lv, d, _("Insert Tabular")),
-         dialog_(0)
-{
-       // 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));
-}
 
+using std::make_pair;
 
-FormTabularCreate::~FormTabularCreate()
-{
-       delete dialog_;
-}
 
+typedef FormController<ControlTabularCreate, FormView<FD_tabular_create> > base_class;
 
-FL_FORM * FormTabularCreate::form() const
-{
-       if (dialog_ ) return dialog_->form;
-       return 0;
-}
-
-
-void FormTabularCreate::connect()
-{
-       bc_.valid(true);
-       FormBaseBD::connect();
-}
+FormTabularCreate::FormTabularCreate(Dialog & parent)
+       : base_class(parent, _("Insert Tabular"))
+{}
 
 
 void FormTabularCreate::build()
 {
-       dialog_ = build_tabular_create();
-
-       // Workaround dumb xforms sizing bug
-       minw_ = form()->w;
-       minh_ = form()->h;
-
-       fl_set_slider_bounds(dialog_->slider_rows, 1, 50);
-       fl_set_slider_bounds(dialog_->slider_columns, 1, 50);
-       fl_set_slider_value(dialog_->slider_rows, 5);
-       fl_set_slider_value(dialog_->slider_columns, 5);
-       fl_set_slider_precision(dialog_->slider_rows, 0);
-       fl_set_slider_precision(dialog_->slider_columns, 0);
-
-        // manage the ok, apply and cancel/close buttons
-       bc_.setOK(dialog_->button_ok);
-       bc_.setApply(dialog_->button_apply);
-       bc_.setCancel(dialog_->button_cancel);
-       bc_.refresh();
+       dialog_.reset(build_tabular_create(this));
+
+       // Manage the ok, apply and cancel/close buttons
+       bcview().setOK(dialog_->button_ok);
+       bcview().setApply(dialog_->button_apply);
+       bcview().setCancel(dialog_->button_close);
+
+       // set up the tooltips
+       string str = _("Number of columns in the tabular.");
+       tooltips().init(dialog_->slider_columns, str);
+       str = _("Number of rows in the tabular.");
+       tooltips().init(dialog_->slider_rows, str);
 }
 
 
 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);
+       unsigned int ysize = (unsigned int)(fl_get_slider_value(dialog_->slider_columns) + 0.5);
+       unsigned int xsize = (unsigned int)(fl_get_slider_value(dialog_->slider_rows) + 0.5);
 
-       InsetTabular * in = new InsetTabular( *lv_->buffer(), xsize, ysize );
-       if (!lv_->view()->open_new_inset(in)) {
-               delete in;
-       }
+       controller().params() = make_pair(xsize, ysize);
 }