]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPrint.C
try this for distinguishing inner and outer tabs
[lyx.git] / src / frontends / xforms / FormPrint.C
index 4ae24cd23093dc61d848568b09a8741ce256b329..884e544edbbbc645d80185a8adfd26f66a4270a6 100644 (file)
@@ -21,7 +21,8 @@
 #include "Liason.h"
 #include "debug.h"
 #include "BufferView.h"
-#include "lyx_gui_misc.h"      // WriteAlert
+#include "lyx_gui_misc.h"      // WriteAlert
+#include "xform_helpers.h"     // for browseFile
 
 #ifdef SIGC_CXX_NAMESPACES
 using SigC::slot;
@@ -32,10 +33,10 @@ using Liason::printBuffer;
 using Liason::getPrinterParams;
 #endif
 
+using std::make_pair;
 
 FormPrint::FormPrint(LyXView * lv, Dialogs * d)
-       : FormBase(lv, d, _("Print"),
-                  BUFFER_DEPENDENT, HIDE, new OkApplyCancelPolicy),
+       : FormBaseBD(lv, d, _("Print"), new OkApplyCancelPolicy),
          dialog_(0), target_(2), order_(2), which_(3)
 {
        // let the dialog be shown
@@ -55,7 +56,11 @@ void FormPrint::build()
 {
        dialog_ = build_print();
 
-       // manage the ok, apply and cancel/close buttons
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
+
+       // Manage the ok, apply and cancel/close buttons
        bc_.setOK(dialog_->button_ok);
        bc_.setApply(dialog_->button_apply);
        bc_.setCancel(dialog_->button_cancel);
@@ -108,15 +113,6 @@ void FormPrint::build()
 }
 
 
-void FormPrint::connect()
-{
-       FormBase::connect();
-       fl_set_form_minsize(dialog_->form,
-                           dialog_->form->w,
-                           dialog_->form->h);
-}
-
-
 FL_FORM * FormPrint::form() const
 {
        if (dialog_) return dialog_->form;
@@ -200,6 +196,7 @@ void FormPrint::update()
 
                fl_set_input(dialog_->input_count,
                             tostr(pp.count_copies).c_str());
+               bc_.valid(true);
        }
 }
 
@@ -207,7 +204,7 @@ void FormPrint::update()
 // It would be nice if we checked for cases like:
 // Print only-odd-pages and from_page == an even number
 //
-bool FormPrint::input(FL_OBJECT *, long)
+bool FormPrint::input(FL_OBJECT * ob, long)
 {
        bool activate = true;
 
@@ -242,6 +239,10 @@ bool FormPrint::input(FL_OBJECT *, long)
                activate = false;
        }
 
+       if (ob == dialog_->button_browse) {
+               browse();
+       }
+               
        // it is probably legal to have no printer name since the system will
        // have a default printer set.  Or should have.
 //     if (fl_get_button(dialog_->radio_printer)
@@ -250,3 +251,25 @@ bool FormPrint::input(FL_OBJECT *, long)
 //     }
        return activate;
 }
+
+
+void FormPrint::browse()
+{
+       // Get the filename from the dialog
+       string const filename = fl_get_input(dialog_->input_file);
+
+       string const title = N_("Print to file");
+       string const pattern = "*.ps";
+
+       // Show the file browser dialog
+       string const new_filename =
+               browseFile(filename, title, pattern,
+                          make_pair(string(), string()),
+                          make_pair(string(), string()));
+
+       // Save the filename to the dialog
+       if (new_filename != filename && !new_filename.empty()) {
+               fl_set_input(dialog_->input_file, new_filename.c_str());
+               input(0, 0);
+       }
+}