Another array -> std::vector...

Andre'

-- 
André Pönitz ........................................ [EMAIL PROTECTED]
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.16
diff -u -p -r1.16 ChangeLog
--- ChangeLog   2001/02/12 18:06:56     1.16
+++ ChangeLog   2001/02/12 19:20:16
@@ -4,6 +4,8 @@
          std::vector<MathMacroArgument>
        * math_defs.h:
          math_inset.C: replace int[] with std::vector<int>
+       * math_panel.h:
+               math_symbols.C: replace FL_OBJECTP[] with std::vector<FL_OBJECT*>
 
 2001-02-12  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
Index: math_panel.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_panel.h,v
retrieving revision 1.10
diff -u -p -r1.10 math_panel.h
--- math_panel.h        2000/08/07 20:58:23     1.10
+++ math_panel.h        2001/02/12 19:20:16
@@ -20,6 +20,7 @@
 #pragma interface
 #endif
 
+#include <vector>
 #include "bmtable.h"                 
 
 ///
@@ -65,21 +66,20 @@ enum SomeMathValues {
 };
 
 ///
-typedef FL_OBJECT * FL_OBJECTP;
-
 /// Class to manage bitmap menu bars
 class BitmapMenu {
    ///
    static BitmapMenu * active;
    ///
    friend int peek_event(FL_FORM *, void *);
-protected:
+   ///
+   typedef std::vector<FL_OBJECT *>   bitmaps_type;
+   ///
+   typedef bitmaps_type::size_type    size_type;
    ///
    BitmapMenu * next, * prev;
-   /// Number of bitmaps
-   int nb;
    /// Current bitmap
-   int i;
+   size_type current_;
    /// Border width
    int ww;
    ///
@@ -87,7 +87,7 @@ protected:
    ///
    FL_FORM * form;
    ///
-   FL_OBJECTP * bitmap;
+   bitmaps_type bitmaps_;
    ///
    FL_OBJECT * button;
  public:
Index: math_symbols.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_symbols.C,v
retrieving revision 1.35
diff -u -p -r1.35 math_symbols.C
--- math_symbols.C      2001/02/02 19:52:29     1.35
+++ math_symbols.C      2001/02/12 19:20:16
@@ -130,15 +130,14 @@ bool math_insert_greek(char c);
 
 BitmapMenu * BitmapMenu::active = 0;
 
-BitmapMenu::BitmapMenu(int n,  FL_OBJECT * bt, BitmapMenu * prevx): nb(n)
+BitmapMenu::BitmapMenu(int n,  FL_OBJECT * bt, BitmapMenu * prevx)
+       : bitmaps_(n), current_(0)
 {
    w = h = 0;
    form = 0;
-   i = 0;
    ww = 2 * FL_abs(FL_BOUND_WIDTH);
    x = y = ww;
    y += 8;
-   bitmap = new FL_OBJECTP[nb];
    button = bt;
    button->u_vdata = this;
    prev = prevx;
@@ -153,7 +152,6 @@ BitmapMenu::~BitmapMenu()
        delete next;
        if (form->visible) Hide();
        fl_free_form(form);  
-       delete[] bitmap;
 }
 
 
@@ -180,7 +178,7 @@ FL_OBJECT *
 BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh,
                      unsigned char const * data, Bool vert)
 {
-   if (i >= nb)
+   if (current_ >= bitmaps_.size())
      return 0;
    int wx = bw+ww/2, wy = bh+ww/2;
    wx += (wx % nx);
@@ -199,20 +197,20 @@ BitmapMenu::AddBitmap(int id, int nx, in
       w = max(x, w);
       h = max(y + wy + ww, h);
    }
-   bitmap[i++] = obj;
+   bitmaps_[current_++] = obj;
    return obj;
 }
 
 void BitmapMenu::Create()
 {
-   if (i < nb)  {
+   if (current_ < bitmaps_.size())  {
           lyxerr << "Error: Bitmaps not created!" << endl;
       return;
    }
    form = fl_bgn_form(FL_UP_BOX, w, h);   
-   for (i = 0; i < nb; ++i) {
-      fl_add_object(form, bitmap[i]);
-      bitmap[i]->u_vdata = this;
+   for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
+      fl_add_object(form, bitmaps_[current_]);
+      bitmaps_[current_]->u_vdata = this;
    }
    fl_end_form();
    fl_register_raw_callback(form, KeyPressMask, C_peek_event);
@@ -222,10 +220,10 @@ int BitmapMenu::GetIndex(FL_OBJECT* ob)
 {
    if (active == this) {
       int k = 0;
-      for (i = 0; i < nb; ++i) {
-        if (bitmap[i] == ob) 
+      for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
+        if (bitmaps_[current_] == ob) 
           return k+fl_get_bmtable(ob);
-        k += fl_get_bmtable_maxitems(bitmap[i]);
+        k += fl_get_bmtable_maxitems(bitmaps_[current_]);
       }
    }
    return -1;

Reply via email to