]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_symbols.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / mathed / math_symbols.C
index 4457fc29e892a4b610678faaa049e50815d8e757..c3a0bc56d3f79f13c6ffbd736b10ddb72271ef2c 100644 (file)
 #pragma implementation "math_panel.h"
 #endif
 
+#include <algorithm>
+using std::max;
+
 #include "lyx_main.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "minibuffer.h"
 #include "lyxrc.h"
-#include "lyxlib.h"
 #include "LyXView.h"
-#include "error.h"
+#include "support/lstrings.h"
+#include "debug.h"
 
 #include "formula.h"
 
 #include "math_panel.h"                 
 #include "math_parser.h"
 
-//     $Id: math_symbols.C,v 1.1 1999/09/27 18:44:40 larsbj Exp $      
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: math_symbols.C,v 1.1 1999/09/27 18:44:40 larsbj Exp $";
-#endif /* lint */
-
 extern void SmallUpdate(signed char);
 extern void BeforeChange();
 extern void Update(signed char);
@@ -136,12 +133,12 @@ static signed char Latin2Greek[] =  {
 }; 
 
 extern char** mathed_get_pixmap_from_icon(int d);
-static void math_cb(FL_OBJECT*, long);
+extern "C" void math_cb(FL_OBJECT*, long);
 static char** pixmapFromBitmapData(char const *, int, int);
 void math_insert_symbol(char const* s);
 Bool math_insert_greek(char const c);
 
-BitmapMenu *BitmapMenu::active = NULL;
+BitmapMenu *BitmapMenu::active = 0;
 
 BitmapMenu::BitmapMenu(int n,  FL_OBJECT* bt, BitmapMenu* prevx): nb(n)  {
    w = h = 0;
@@ -154,7 +151,7 @@ BitmapMenu::BitmapMenu(int n,  FL_OBJECT* bt, BitmapMenu* prevx): nb(n)  {
    button = bt;
    button->u_vdata = this;
    prev = prevx;
-   next = NULL;
+   next = 0;
    if (prev)
      prev->next = this;
 }
@@ -169,7 +166,7 @@ BitmapMenu::~BitmapMenu() {
 void BitmapMenu::Hide()  {
    fl_hide_form(form);
    fl_set_button(button, 0);
-   active = NULL;
+   active = 0;
 }
 
 void BitmapMenu::Show()  {
@@ -183,10 +180,10 @@ void BitmapMenu::Show()  {
 }
 
 FL_OBJECT*
-BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, char* data, Bool vert)
+BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* data, Bool vert)
 {
    if (i>=nb)
-     return NULL;
+     return 0;
    int wx=bw+ww/2, wy=bh+ww/2;
    wx += (wx % nx);
    wy += (wy % ny); 
@@ -197,12 +194,12 @@ BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, char* data, Bool v
    fl_set_bmtable_data(obj, nx, ny, bw, bh, data);
    if (vert) { 
       y += wy + 8;
-      h = Maximum(y, h);
-      w = Maximum(x + wx + ww, w);
+      h = max(y, h);
+      w = max(x + wx + ww, w);
    } else  {
       x += wx + 8;
-      w = Maximum(x, w);
-      h = Maximum(y + wy + ww, h);
+      w = max(x, w);
+      h = max(y + wy + ww, h);
    }
    bitmap[i++] = obj;
    return obj;
@@ -211,7 +208,7 @@ BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, char* data, Bool v
 void BitmapMenu::Create()
 {
    if (i<nb)  {
-      fprintf(stderr, "Error: Bitmaps not created!");
+          lyxerr << "Error: Bitmaps not created!" << endl;
       return;
    }
    form = fl_bgn_form(FL_UP_BOX, w, h);   
@@ -220,7 +217,7 @@ void BitmapMenu::Create()
       bitmap[i]->u_vdata = this;
    }
    fl_end_form();
-   fl_register_raw_callback(form, KeyPressMask, peek_event);
+   fl_register_raw_callback(form, KeyPressMask, C_peek_event);
 }
 
 int BitmapMenu::GetIndex(FL_OBJECT* ob)
@@ -238,7 +235,7 @@ int BitmapMenu::GetIndex(FL_OBJECT* ob)
 
 int peek_event(FL_FORM * /*form*/, void *xev)
 {
-   if (BitmapMenu::active==NULL)
+   if (BitmapMenu::active==0)
      return 0;
   
    if(((XEvent *)xev)->type == ButtonPress)
@@ -250,7 +247,7 @@ int peek_event(FL_FORM * /*form*/, void *xev)
    {
       char c[5];
       KeySym keysym;
-      XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, NULL);
+      XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, 0);
       if (keysym==XK_Left) 
        BitmapMenu::active->Prev(); else
       if (keysym==XK_Right) 
@@ -262,13 +259,19 @@ int peek_event(FL_FORM * /*form*/, void *xev)
    return 0;  
 }
 
-static void math_cb(FL_OBJECT* ob, long data)
+// This is just a wrapper.
+extern "C" int C_peek_event(FL_FORM *form, void *ptr) {
+  return peek_event(form,ptr);
+}
+
+
+extern "C" void math_cb(FL_OBJECT* ob, long data)
 {
    BitmapMenu* menu = (BitmapMenu*)ob->u_vdata;
    int i = menu->GetIndex(ob);   
    char const *s = 0;
 
-//   fprintf(stderr, "data[%d]", data);     
+//   lyxerr << "data[" << data << "]";
    if (i<0) return;
    switch (data)  {
     case MM_GREEK: 
@@ -290,7 +293,7 @@ static void math_cb(FL_OBJECT* ob, long data)
       s = latex_misc[i];  
       break;
     case MM_DOTS: 
-//      fprintf(stderr, "dots[%s %d]", latex_dots[i], i);
+//      lyxerr << "dots[" << latex_dots[i] << " " << i << "]";
       s = latex_dots[i-29];  
       break;
    }
@@ -307,10 +310,10 @@ static void math_cb(FL_OBJECT* ob, long data)
 
 char** get_pixmap_from_symbol(char const *arg, int wx, int hx)
 {
-   char** data=NULL;                       
+   char** data=0;                  
    latexkeys *l = in_word_set (arg, strlen(arg));
    if (!l) 
-    return NULL;
+    return 0;
     
    switch (l->token) {
     case LM_TK_FRAC:
@@ -334,7 +337,7 @@ char** get_pixmap_from_symbol(char const *arg, int wx, int hx)
 Bool math_insert_greek(char const c)
 {
    int i;
-   char const *s=NULL;
+   char const *s=0;
    
    if ('A'<=c && c<='Z') {
       if ((i=Latin2Greek[c - 'A'])>=0)
@@ -369,7 +372,8 @@ void math_insert_symbol(char const* s)
        if (current_view->currentBuffer()->the_locking_inset->LyxCode()==Inset::MATH_CODE)
          ((InsetFormula*)current_view->currentBuffer()->the_locking_inset)->InsertSymbol(s);
         else 
-         fprintf(stderr, "Math error: attempt to write on a wrong class of inset.\n");
+               lyxerr << "Math error: attempt to write on a wrong "
+                       "class of inset." << endl;
    }
 }
 
@@ -453,10 +457,10 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx)
        if (id>=0) break;
     }
     if (i<6 && id>=0) {
-       char *bdata = 0;
+       unsigned char *bdata = 0;
        int w = 0, h = 0, dw = 0, dh = 0;
 
-       lyxerr.debug(LString("Imando ") + int(i) + ", " + int(id), Error::MATHED);
+       lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
        switch (i) {
         case 0: 
            if (id<=10) {
@@ -519,8 +523,8 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx)
        }
        int ww = w/dw, hh = h/dh, x, y;
    
-       XImage *xima = XCreateImage(fl_display, NULL, 1, XYBitmap, 0, 
-                                   bdata, w, h, 8, 0);
+       XImage *xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0, 
+                                   reinterpret_cast<char*>(bdata), w, h, 8, 0);
        xima->byte_order = LSBFirst;
        xima->bitmap_bit_order = LSBFirst;
        x = (id % dw)*ww;