]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormBase.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormBase.C
index 317135ea29a815d6a687f8b4fde56fc1b89ed1b3..4486572f8846d55616ad08e1c690dd35232d95e3 100644 (file)
@@ -1,9 +1,11 @@
 /**
  * \file FormBase.C
- * Copyright 2000-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Angus Leeming 
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 #pragma implementation
 #endif
 
-#include "Dialogs.h"
 #include "FormBase.h"
+
+#include "ControlButtons.h"
 #include "xformsBC.h"
 #include "xforms_resize.h"
 #include "Tooltips.h"
+
 #include "support/LAssert.h"
+#include "support/filetools.h" //  LibFileSearch
+
 #include FORMS_H_LOCATION
 
 extern "C" {
@@ -32,10 +38,9 @@ static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *);
 } // extern "C"
 
 
-FormBase::FormBase(ControlButtons & c, Dialogs & d,
-                  string const & t, bool allowResize)
-       : ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
-         title_(t), tooltips_(new Tooltips(d))
+FormBase::FormBase(string const & t, bool allowResize)
+       : ViewBase(), minw_(0), minh_(0), allow_resize_(allowResize),
+         title_(t), tooltips_(new Tooltips())
 {}
 
 
@@ -58,9 +63,15 @@ void FormBase::redraw()
 }
 
 
+xformsBC & FormBase::bc()
+{
+       return static_cast<xformsBC &>(getController().bc());
+       // return dynamic_cast<GUIbc &>(controller_ptr_->bc());
+}
+
+
 void FormBase::show()
 {
-       lyxerr << "show" << endl;
        if (!form()) {
                build();
        }
@@ -103,10 +114,34 @@ void FormBase::show()
                if (!allow_resize_)
                        fl_set_form_maxsize(form(), minw_, minh_);
 
+               string const maximize_title = "LyX: " + title_;
+               int const iconify_policy = getController().IconifyWithMain() ?
+                                               FL_TRANSIENT : 0;
+
                fl_show_form(form(),
                             FL_PLACE_MOUSE | FL_FREE_SIZE,
-                            (controller_.IconifyWithMain() ? FL_TRANSIENT : 0),
-                            title_.c_str());
+                            iconify_policy,
+                            maximize_title.c_str());
+
+               if (iconify_policy == 0) {
+                       // set title for minimized form
+                       string const minimize_title = title_;
+                       fl_winicontitle(form()->window, minimize_title.c_str());
+
+                       //  assign an icon to form
+                       string const iconname = LibFileSearch("images", "lyx", "xpm");
+                       if (!iconname.empty()) {
+                               unsigned int w, h;
+                               Pixmap icon_mask;
+                               Pixmap const icon_p = fl_read_pixmapfile(fl_root,
+                                                       iconname.c_str(),
+                                                       &w,
+                                                       &h,
+                                                       &icon_mask,
+                                                       0, 0, 0); // this leaks
+                               fl_set_form_icon(form(), icon_p, icon_mask);
+                       }
+               }
        }
 
        tooltips().set();
@@ -167,26 +202,26 @@ extern "C" {
 
 void C_FormBaseApplyCB(FL_OBJECT * ob, long)
 {
-       GetForm(ob)->ApplyButton();
+       GetForm(ob)->getController().ApplyButton();
 }
 
 
 void C_FormBaseOKCB(FL_OBJECT * ob, long)
 {
-       GetForm(ob)->OKButton();
+       GetForm(ob)->getController().OKButton();
 }
 
 
 void C_FormBaseCancelCB(FL_OBJECT * ob, long)
 {
        FormBase * form = GetForm(ob);
-       form->CancelButton();
+       form->getController().CancelButton();
 }
 
 
 void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
 {
-       GetForm(ob)->RestoreButton();
+       GetForm(ob)->getController().RestoreButton();
 }
 
 
@@ -201,7 +236,7 @@ static int C_WMHideCB(FL_FORM * form, void *)
        // Close the dialog cleanly, even if the WM is used to do so.
        lyx::Assert(form && form->u_vdata);
        FormBase * ptr = static_cast<FormBase *>(form->u_vdata);
-       ptr->CancelButton();
+       ptr->getController().CancelButton();
        return FL_CANCEL;
 }