I suspect that the same thing could be done to most of the forms.
(this change alone reduces binary size with some ~300 bytes. "Who
Cares!" I hear you yell. Well I do... "mange små blir en stor å")

Lgb

Index: FormParagraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.C,v
retrieving revision 1.15
diff -u -p -r1.15 FormParagraph.C
--- FormParagraph.C     2001/02/14 08:38:21     1.15
+++ FormParagraph.C     2001/03/02 14:04:00
@@ -31,8 +31,7 @@ using Liason::setMinibuffer;
 
 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
        : FormBaseBD(lv, d, _("Paragraph Layout"),
-                    new NoRepeatedApplyReadOnlyPolicy),
-       dialog_(0), general_(0), extra_(0)
+                    new NoRepeatedApplyReadOnlyPolicy)
 {
     // let the popup be shown
     // This is a permanent connection so we won't bother
@@ -41,14 +40,6 @@ FormParagraph::FormParagraph(LyXView * l
 }
 
 
-FormParagraph::~FormParagraph()
-{
-    delete general_;
-    delete extra_;
-    delete dialog_;
-}
-
-
 void FormParagraph::redraw()
 {
        if( form() && form()->visible )
@@ -64,7 +55,7 @@ void FormParagraph::redraw()
 
 FL_FORM * FormParagraph::form() const
 {
-    if (dialog_) return dialog_->form;
+    if (dialog_.get()) return dialog_->form;
     return 0;
 }
 
@@ -72,7 +63,7 @@ FL_FORM * FormParagraph::form() const
 void FormParagraph::build()
 {
     // the tabbed folder
-    dialog_ = build_tabbed_paragraph();
+    dialog_.reset(build_tabbed_paragraph());
 
     // Workaround dumb xforms sizing bug
     minw_ = form()->w;
@@ -86,7 +77,7 @@ void FormParagraph::build()
     bc_.refresh();
 
     // the general paragraph data form
-    general_ = build_paragraph_general();
+    general_.reset(build_paragraph_general());
 
     fl_addto_choice(general_->choice_space_above,
                    _(" None | Defskip | Smallskip "
@@ -117,7 +108,7 @@ void FormParagraph::build()
     bc_.addReadOnly (general_->input_labelwidth);
 
     // the document class form
-    extra_ = build_paragraph_extra();
+    extra_.reset(build_paragraph_extra());
 
     fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
     fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
@@ -136,7 +127,7 @@ void FormParagraph::build()
 
 void FormParagraph::apply()
 {
-    if (!lv_->view()->available() || !dialog_)
+    if (!lv_->view()->available() || !dialog_.get())
        return;
 
     general_apply();
@@ -151,7 +142,7 @@ void FormParagraph::apply()
 
 void FormParagraph::update()
 {
-    if (!dialog_)
+    if (!dialog_.get())
         return;
 
     general_update();
@@ -162,7 +153,8 @@ void FormParagraph::update()
 
 void FormParagraph::general_apply()
 {
-    VSpace space_top, space_bottom;
+    VSpace space_top;
+    VSpace space_bottom;
     LyXAlignment align;
     string labelwidthstring;
     bool noindent;
@@ -172,12 +164,12 @@ void FormParagraph::general_apply()
     if ((fl_get_choice (general_->choice_space_above) == 7) &&
        !*(fl_get_input (general_->input_space_above)))
     {
-       fl_set_choice (general_->choice_space_above, 1);
+       fl_set_choice(general_->choice_space_above, 1);
     }
-    if ((fl_get_choice (general_->choice_space_below) == 7) &&
-       !*(fl_get_input (general_->input_space_below)))
+    if ((fl_get_choice(general_->choice_space_below) == 7) &&
+       !*(fl_get_input(general_->input_space_below)))
     {
-       fl_set_choice (general_->choice_space_below, 1);
+       fl_set_choice(general_->choice_space_below, 1);
     }
    
     bool line_top = fl_get_button(general_->check_lines_top);
@@ -185,7 +177,7 @@ void FormParagraph::general_apply()
     bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
     bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
     
-    switch (fl_get_choice (general_->choice_space_above)) {
+    switch (fl_get_choice(general_->choice_space_above)) {
     case 1:
        space_top = VSpace(VSpace::NONE);
        break;
@@ -209,9 +201,9 @@ void FormParagraph::general_apply()
                VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
        break;
     }
-    if (fl_get_button (general_->check_space_above))
-       space_top.setKeep (true);
-    switch (fl_get_choice (general_->choice_space_below)) {
+    if (fl_get_button(general_->check_space_above))
+       space_top.setKeep(true);
+    switch (fl_get_choice(general_->choice_space_below)) {
     case 1:
        space_bottom = VSpace(VSpace::NONE);
        break;
@@ -236,7 +228,7 @@ void FormParagraph::general_apply()
        break;
     }
     if (fl_get_button (general_->check_space_below))
-       space_bottom.setKeep (true);
+       space_bottom.setKeep(true);
 
     if (fl_get_button(general_->radio_align_left))
        align = LYX_ALIGN_LEFT;
@@ -263,15 +255,14 @@ void FormParagraph::general_apply()
 
 void FormParagraph::extra_apply()
 {
-    char const * width = fl_get_input(extra_->input_pextra_width);
-    char const * widthp = fl_get_input(extra_->input_pextra_widthp);
+    char const * const width = fl_get_input(extra_->input_pextra_width);
+    char const * const widthp = fl_get_input(extra_->input_pextra_widthp);
     LyXText * text = lv_->view()->text;
     int type = LyXParagraph::PEXTRA_NONE;
     LyXParagraph::MINIPAGE_ALIGNMENT
        alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
-    bool
-       hfill = false,
-       start_minipage = false;
+    bool hfill = false;
+    bool start_minipage = false;
 
     if (fl_get_button(extra_->radio_pextra_indent)) {
        type = LyXParagraph::PEXTRA_INDENT;
@@ -295,7 +286,7 @@ void FormParagraph::extra_apply()
 
 void FormParagraph::general_update()
 {
-    if (!general_)
+    if (!general_.get())
         return;
 
     Buffer * buf = lv_->view()->buffer();
@@ -469,7 +460,7 @@ void FormParagraph::general_update()
 
 void FormParagraph::extra_update()
 {
-    if (!lv_->view()->available() || !extra_)
+    if (!lv_->view()->available() || !extra_.get())
         return;
 
     LyXParagraph * par = lv_->view()->text->cursor.par();
@@ -574,7 +565,7 @@ bool FormParagraph::input(FL_OBJECT * ob
     // then the extra form
     //
     if (ob == extra_->radio_pextra_indent) {
-       int n = fl_get_button(extra_->radio_pextra_indent);
+       int const n = fl_get_button(extra_->radio_pextra_indent);
        if (n) {
            fl_set_button(extra_->radio_pextra_minipage, 0);
            fl_set_button(extra_->radio_pextra_floatflt, 0);
@@ -599,7 +590,7 @@ bool FormParagraph::input(FL_OBJECT * ob
        fl_activate_object(extra_->radio_pextra_startmp);
        fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
     } else if (ob == extra_->radio_pextra_minipage) {
-       int n = fl_get_button(extra_->radio_pextra_minipage);
+       int const n = fl_get_button(extra_->radio_pextra_minipage);
        if (n) {
            fl_set_button(extra_->radio_pextra_indent, 0);
            fl_set_button(extra_->radio_pextra_floatflt, 0);
@@ -634,7 +625,7 @@ bool FormParagraph::input(FL_OBJECT * ob
            fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
        }
     } else if (ob == extra_->radio_pextra_floatflt) {
-       int n = fl_get_button(extra_->radio_pextra_floatflt);
+       int const n = fl_get_button(extra_->radio_pextra_floatflt);
        if (n) {
            fl_set_button(extra_->radio_pextra_indent, 0);
            fl_set_button(extra_->radio_pextra_minipage, 0);
@@ -689,11 +680,11 @@ bool FormParagraph::input(FL_OBJECT * ob
     //
     // then the extra form
     //
-    int n = fl_get_button(extra_->radio_pextra_indent) +
+    int const n = fl_get_button(extra_->radio_pextra_indent) +
        fl_get_button(extra_->radio_pextra_minipage) +
        fl_get_button(extra_->radio_pextra_floatflt);
-    string s1 = fl_get_input(extra_->input_pextra_width);
-    string s2 = fl_get_input(extra_->input_pextra_widthp);
+    string const s1 = fl_get_input(extra_->input_pextra_width);
+    string const s2 = fl_get_input(extra_->input_pextra_widthp);
     if (!n) { // no button pressed both should be deactivated now
        fl_deactivate_object(extra_->input_pextra_width);
        fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
@@ -732,4 +723,3 @@ bool FormParagraph::input(FL_OBJECT * ob
     }
     return ret;
 }
-
Index: FormParagraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.h,v
retrieving revision 1.7
diff -u -p -r1.7 FormParagraph.h
--- FormParagraph.h     2000/11/10 17:29:46     1.7
+++ FormParagraph.h     2001/03/02 14:04:00
@@ -13,6 +13,8 @@
 #ifndef FORM_PARAGRAPH_H
 #define FORM_PARAGRAPH_H
 
+#include <boost/smart_ptr.hpp>
+
 #include "FormBase.h"
 
 #ifdef __GNUG_
@@ -32,7 +34,7 @@ public:
        ///
        FormParagraph(LyXView *, Dialogs *);
        ///
-       ~FormParagraph();
+       //~FormParagraph();
 
 private:
        /** Redraw the form (on receipt of a Signal indicating, for example,
@@ -67,11 +69,11 @@ private:
        FD_form_paragraph_extra * build_paragraph_extra();
 
        /// Real GUI implementation.
-       FD_form_tabbed_paragraph  * dialog_;
+       boost::scoped_ptr<FD_form_tabbed_paragraph> dialog_;
        ///
-       FD_form_paragraph_general * general_;
+       boost::scoped_ptr<FD_form_paragraph_general> general_;
        ///
-       FD_form_paragraph_extra   * extra_;
+       boost::scoped_ptr<FD_form_paragraph_extra> extra_;
 };
 
 #endif

Reply via email to