]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormForks.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / FormForks.C
index 524c8346cc23e6ce62535a071b25fc624e7d0c56..467b141c54a7c69758bc2eddc13c096eafc47d98 100644 (file)
@@ -1,40 +1,42 @@
 /**
  * \file FormForks.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
  * \date 2001-10-22
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "xformsBC.h"
+#include "ButtonController.h"
 #include "FormForks.h"
 #include "ControlForks.h"
-#include "form_forks.h"
-#include "gettext.h"
+#include "forms/form_forks.h"
+#include "Tooltips.h"
 #include "helper_funcs.h"
 #include "xforms_helpers.h"
+#include "gettext.h"
 #include "support/lstrings.h"
+#include FORMS_H_LOCATION
 
 using std::vector;
 using std::find;
 using std::find_if;
 
-typedef FormCB<ControlForks, FormDB<FD_form_forks> > base_class;
+typedef FormCB<ControlForks, FormDB<FD_forks> > base_class;
 
-FormForks::FormForks(ControlForks & c)
-       : base_class(c, _("Child processes"))
+FormForks::FormForks()
+       : base_class(_("Child processes"))
 {}
 
 
 void FormForks::build() {
-       dialog_.reset(build_forks());
+       dialog_.reset(build_forks(this));
 
        // It appears that the browsers aren't initialised properly.
        // This fudge fixes tings.
@@ -43,18 +45,31 @@ void FormForks::build() {
        fl_clear_browser(dialog_->browser_children);
        fl_clear_browser(dialog_->browser_kill);
 
-        // Manage the ok, apply, restore and cancel/close buttons
-       bc().setOK(dialog_->button_ok);
-       bc().setApply(dialog_->button_apply);
-       bc().setCancel(dialog_->button_close);
-       bc().invalid();
+       // Manage the ok, apply, restore and cancel/close buttons
+       bcview().setOK(dialog_->button_ok);
+       bcview().setApply(dialog_->button_apply);
+       bcview().setCancel(dialog_->button_close);
+       bc().valid(false);
 
        // Set up the tooltip mechanism
-       setTooltipHandler(dialog_->browser_children);
-       setTooltipHandler(dialog_->browser_kill);
-       setTooltipHandler(dialog_->button_all);
-       setTooltipHandler(dialog_->button_add);
-       setTooltipHandler(dialog_->button_remove);
+       string str = _("All currently running child processes forked by LyX.");
+       tooltips().init(dialog_->browser_children, str);
+       // Work-around xforms' bug; enable tooltips for browser widgets.
+       setPrehandler(dialog_->browser_children);
+
+       str = _("A list of all child processes to kill.");
+       tooltips().init(dialog_->browser_kill, str);
+       // Work-around xforms' bug; enable tooltips for browser widgets.
+       setPrehandler(dialog_->browser_kill);
+
+       str = _("Add all processes to the list of processes to kill.");
+       tooltips().init(dialog_->button_all, str);
+
+       str = _("Add the currently selected child process to the list of processes to kill.");
+       tooltips().init(dialog_->button_add, str);
+
+       str = _("Remove the currently selected item from the list of processes to kill.");
+       tooltips().init(dialog_->button_remove, str);
 }
 
 
@@ -64,7 +79,7 @@ void FormForks::update()
                return;
 
        string const current_pid_str =
-               getSelectedStringFromBrowser(dialog_->browser_kill);
+               getString(dialog_->browser_kill);
        pid_t const current_pid = strToInt(current_pid_str);
 
        vector<pid_t> pids = controller().getPIDs();
@@ -90,7 +105,7 @@ void FormForks::update()
        for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_kill);
             ++i) {
                string const pid_str =
-                       getStringFromBrowser(dialog_->browser_kill, i);
+                       getString(dialog_->browser_kill, i);
                pid_t const pid = strToInt(pid_str);
                vector<pid_t>::const_iterator it =
                        find(pids.begin(), pids.end(), pid);
@@ -125,7 +140,7 @@ void FormForks::apply()
 {
        // Get the list of all processes to kill.
        vector<string> const kill_vec =
-               getVectorFromBrowser(dialog_->browser_kill);
+               getVector(dialog_->browser_kill);
 
        if (kill_vec.empty())
                return;
@@ -134,7 +149,7 @@ void FormForks::apply()
        for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_children);
             ++i) {
                string const selection =
-                       getStringFromBrowser(dialog_->browser_children, i);
+                       getString(dialog_->browser_children, i);
                string pid_str;
                split(selection, pid_str, '\t');
 
@@ -166,7 +181,7 @@ ButtonPolicy::SMInput FormForks::input(FL_OBJECT * ob, long)
 
        if (ob == dialog_->browser_children) {
                activate = input_browser_children();
-               
+
        } else if (ob == dialog_->browser_kill) {
                activate = input_browser_kill();
 
@@ -198,12 +213,12 @@ ButtonPolicy::SMInput FormForks::input_browser_children()
        //    be added to this list if so desired.
 
        string const selection =
-               getSelectedStringFromBrowser(dialog_->browser_children);
+               getString(dialog_->browser_children);
        string pid_str;
        split(selection, pid_str, '\t');
 
-       vector<string> const kill_vec = 
-               getVectorFromBrowser(dialog_->browser_kill);
+       vector<string> const kill_vec =
+               getVector(dialog_->browser_kill);
 
        vector<string>::const_iterator it =
                find(kill_vec.begin(), kill_vec.end(), pid_str);
@@ -240,7 +255,7 @@ public:
 private:
        string pid_;
 };
+
 } // namespace anon
 
 
@@ -257,11 +272,11 @@ ButtonPolicy::SMInput FormForks::input_browser_kill()
        // 3. Disable the add button.
 
        string const pid_str =
-               getSelectedStringFromBrowser(dialog_->browser_kill);
+               getString(dialog_->browser_kill);
 
        // Find this string in the list of all child processes
        vector<string> const child_vec =
-               getVectorFromBrowser(dialog_->browser_children);
+               getVector(dialog_->browser_children);
 
        vector<string>::const_iterator it =
                find_if(child_vec.begin(), child_vec.end(), FindPID(pid_str));
@@ -272,7 +287,7 @@ ButtonPolicy::SMInput FormForks::input_browser_kill()
                fl_select_browser_line(dialog_->browser_children, n+1);
                fl_set_browser_topline(dialog_->browser_children, n+1);
        }
-               
+
        setEnabled(dialog_->button_remove, true);
        setEnabled(dialog_->button_add,    false);
 
@@ -284,7 +299,7 @@ namespace {
 
 vector<string> const getPIDvector(FL_OBJECT * ob)
 {
-       vector<string> vec = getVectorFromBrowser(ob);
+       vector<string> vec = getVector(ob);
        if (vec.empty())
                return vec;
 
@@ -296,7 +311,7 @@ vector<string> const getPIDvector(FL_OBJECT * ob)
 
        return vec;
 }
+
 } // namespace anon
 
 
@@ -320,7 +335,7 @@ ButtonPolicy::SMInput FormForks::input_button_all()
 
        // to resolve a warning about comparison between signed and unsigned.
        int const pid_vec_size = int(pid_vec.size());
-       
+
        if (fl_get_browser_maxline(dialog_->browser_kill) != pid_vec_size) {
                activate = ButtonPolicy::SMI_VALID;
 
@@ -355,13 +370,12 @@ ButtonPolicy::SMInput FormForks::input_button_add()
 
        // 3. Deactivate the "add" button.
 
-       string const selection =
-               getSelectedStringFromBrowser(dialog_->browser_children);
+       string const selection = getString(dialog_->browser_children);
        string pid_str;
        split(selection, pid_str, '\t');
 
-       vector<string> const kill_vec = 
-               getVectorFromBrowser(dialog_->browser_kill);
+       vector<string> const kill_vec =
+               getVector(dialog_->browser_kill);
 
        vector<string>::const_iterator it =
                find(kill_vec.begin(), kill_vec.end(), pid_str);
@@ -399,25 +413,3 @@ ButtonPolicy::SMInput FormForks::input_button_remove()
 
        return ButtonPolicy::SMI_VALID;
 }
-
-
-string const FormForks::getVerboseTooltip(FL_OBJECT const * ob) const
-{
-       string str;
-       
-       if (ob == dialog_->browser_children) {
-               str = _("All currently running child processes forked by LyX.");
-       } else if (ob == dialog_->browser_kill) {
-               str = _("A list of all child processes to kill.");
-       } else if (ob == dialog_->button_all) {
-               str = _("Add all processes to the list of processes to kill.");
-       } else if (ob == dialog_->button_add) {
-               str = _("Add the currently selected child process to the list of processes to kill.");
-       } else if (ob == dialog_->button_remove) {
-               str = _("Remove the currently selected item from the list of processes to kill.");
-       }
-       
-       return str;
-}
-
-