]> git.lyx.org Git - lyx.git/blobdiff - src/toolbar.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / toolbar.C
index 3992444360bad17295877378692ea3d8f4ff2a91..28ff89134d30e26ab174e1b5f5d119769d4f8344 100644 (file)
@@ -1,15 +1,15 @@
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*
-*          Copyright (C) 1995 Matthias Ettrich
-*           Copyright (C) 1995-1998 The LyX Team.
-*
-*           This file is Copyright 1996-1998
-*           Lars Gullik Bjønnes
-*
-*======================================================*/
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
+ *
+ *           This file is Copyright 1996-1998
+ *           Lars Gullik Bjønnes
+ *
+ * ======================================================*/
 
 //  Added pseudo-action handling, asierra 180296
 
 #include "toolbar.h"
 #include "lyxfunc.h"
 #include "lyxlex.h"
-#include "error.h"
+#include "debug.h"
 #include "combox.h"
 #include "lyx_cb.h"
 #include "LyXView.h"
+#include "support/lstrings.h"
 
 #ifdef TWO_COLOR_ICONS
 #include "cut_bw.xpm"
 #include "layout_std.xpm"
 #include "build.xpm"
 
-
-
-//     $Id: toolbar.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $   
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: toolbar.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $";
-#endif /* lint */
-
+// this one is not "C" because combox callbacks are really C++ %-|
 extern void LayoutsCB(int, void*);
 extern char** get_pixmap_from_symbol(char const *arg, int, int);
 extern LyXAction lyxaction;
@@ -132,34 +126,39 @@ Toolbar::Toolbar(Toolbar const &rct, LyXView *o, int x, int y)
 
        // extracts the toolbar struct form rct.
        toolbarItem *tmplist = rct.toollist;
-       while (tmplist != NULL) {
+       while (tmplist != 0) {
                add(tmplist->action);
-               lyxerr.debug(LString("tool action: ") + int(tmplist->action),
-                             Error::TOOLBAR);
+               lyxerr[Debug::TOOLBAR] << "tool action: "
+                                      << tmplist->action << endl;
                tmplist=tmplist->next;
        }
 }
 
 
 // timer-cb for bubble-help (Matthias)
-void Toolbar::BubbleTimerCB(FL_OBJECT *, long data){
+void Toolbar::BubbleTimerCB(FL_OBJECT *, long data)
+{
        FL_OBJECT* ob = (FL_OBJECT*) data;
        char* help = (char*) ob->u_vdata;
        fl_show_oneliner(help, ob->form->x + ob->x,
                         ob->form->y + ob->y + ob->h);
 }
 
+extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT *ob, long data)
+{
+       Toolbar::BubbleTimerCB(ob, data);
+}
 
 // post_handler for bubble-help (Matthias)
 int Toolbar::BubblePost(FL_OBJECT *ob, int event,
             FL_Coord /*mx*/, FL_Coord /*my*/, int /*key*/, void */*xev*/)
 {
-       LString help = (char *)ob->u_vdata;
+       string help = (char *)ob->u_vdata;
        Toolbar *t = (Toolbar*)ob->u_ldata;
        
        if(event == FL_ENTER && !help.empty()){
                fl_set_object_callback(t->bubble_timer,
-                                      BubbleTimerCB, (long) ob);
+                                      C_Toolbar_BubbleTimerCB, (long) ob);
                fl_set_timer(t->bubble_timer, 1);
        }
        else if(event != FL_MOTION){
@@ -169,10 +168,16 @@ int Toolbar::BubblePost(FL_OBJECT *ob, int event,
        return 0;
 }
 
+extern "C" int C_Toolbar_BubblePost(FL_OBJECT *ob, int event,
+                                  FL_Coord /*mx*/, FL_Coord /*my*/, 
+                                  int key, void *xev)
+{
+       return Toolbar::BubblePost(ob,event,0,0,key,xev);
+}
 
 void Toolbar::activate()
 {
-       toolbarItem *item, *tmp=NULL;
+       toolbarItem *item, *tmp=0;
        item = toollist;
        while(item){
                tmp = item->next;
@@ -186,7 +191,7 @@ void Toolbar::activate()
 
 void Toolbar::deactivate()
 {
-       toolbarItem *item, *tmp=NULL;
+       toolbarItem *item, *tmp=0;
        item = toollist;
        while(item){
                tmp = item->next;
@@ -202,13 +207,17 @@ void Toolbar::ToolbarCB(FL_OBJECT *ob, long ac)
 {
        Toolbar *t = (Toolbar*)ob->u_ldata;
        
-       LString res = t->owner->getLyXFunc()->Dispatch(int(ac));
+       string res = t->owner->getLyXFunc()->Dispatch(int(ac));
        if(!res.empty())
-               lyxerr.debug(res, Error::TOOLBAR); 
+               lyxerr[Debug::TOOLBAR] << res << endl;
 }
 
+extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT *ob, long data)
+{
+       Toolbar::ToolbarCB(ob, data);
+}
 
-int Toolbar::get_toolbar_func(LString const & func)
+int Toolbar::get_toolbar_func(string const & func)
 {
        int action = lyxaction.LookupFunc(func.c_str());
        if (action == -1) {
@@ -277,11 +286,11 @@ void Toolbar::set(bool doingmain)
 #endif
 
        // add the time if it don't exist
-       if (bubble_timer == NULL)
+       if (bubble_timer == 0)
                bubble_timer = fl_add_timer(FL_HIDDEN_TIMER,
                                            xpos,ypos,0,0,"Timer");
        
-       while(item != NULL) {
+       while(item != 0) {
                switch(item->action){
                  case TOOL_SEPARATOR:
                          xpos += sepspace;
@@ -311,7 +320,7 @@ void Toolbar::set(bool doingmain)
                          fl_set_object_gravity(obj,
                                                NorthWestGravity,
                                                NorthWestGravity);
-                         fl_set_object_callback(obj,ToolbarCB,
+                         fl_set_object_callback(obj,C_Toolbar_ToolbarCB,
                                                 (long)item->action);
 #if FL_REVISION >85
                          // Remove the blue feedback rectangle
@@ -324,7 +333,7 @@ void Toolbar::set(bool doingmain)
                          // belongs too. (Lgb)
                          obj->u_ldata = (long) this;
                          
-                         fl_set_object_posthandler(obj, BubblePost);
+                         fl_set_object_posthandler(obj, C_Toolbar_BubblePost);
 
                          fl_set_pixmapbutton_data(obj,item->pixmap);
                          item = item->next;
@@ -353,9 +362,9 @@ void Toolbar::set(bool doingmain)
 }
 
 
-char **Toolbar::getPixmap(kb_action action, LString const & arg)
+char **Toolbar::getPixmap(kb_action action, string const & arg)
 {
-       char **pixmap = unknown_xpm; //NULL
+       char **pixmap = unknown_xpm; //0
        switch(action){
        case LFUN_MENUOPEN:    pixmap = open_xpm; break;
        case LFUN_CLOSEBUFFER: pixmap = close_xpm; break;
@@ -431,8 +440,8 @@ void Toolbar::add(int action, bool doclean)
        if (!doclean && owner) {
                // first «hide» the toolbar buttons. This is not a real hide
                // actually it deletes and frees the button altogether.
-               lyxerr.print("Toolbar::add: «hide» the toolbar buttons.");
-               toolbarItem *item, *tmp=NULL;
+               lyxerr << "Toolbar::add: «hide» the toolbar buttons." << endl;
+               toolbarItem *item, *tmp=0;
                item = toollist;
 
                lightReset();
@@ -456,8 +465,8 @@ void Toolbar::add(int action, bool doclean)
        
        // there exist some special actions not part of
        // kb_action: SEPARATOR, LAYOUTS
-       char **pixmap = NULL;
-       LString help;
+       char **pixmap = 0;
+       string help;
 
        toolbarItem *newItem,*tmp;
 
@@ -468,14 +477,14 @@ void Toolbar::add(int action, bool doclean)
                help = lyxaction.helpText(act);
                help += " ";
                help += arg;
-               lyxerr.debug(LString("Pseudo action ") + int(action));
+               lyxerr.debug() << "Pseudo action " << action << endl;
        } else {
                pixmap = getPixmap((kb_action)action);
                help = lyxaction.helpText((kb_action)action);
        }
        
        // adds an item to the list
-       if (pixmap != NULL
+       if (pixmap != 0
            || action == TOOL_SEPARATOR
            || action == TOOL_LAYOUTS)
        {
@@ -485,10 +494,10 @@ void Toolbar::add(int action, bool doclean)
                newItem->help = help;
                // the new item is placed at the end of the list
                tmp = toollist;
-               if (tmp != NULL){
-                       while(tmp->next != NULL)
+               if (tmp != 0){
+                       while(tmp->next != 0)
                                tmp = tmp->next;
-                       // here is tmp->next == NULL
+                       // here is tmp->next == 0
                        tmp->next = newItem;
                } else
                        toollist = newItem;
@@ -499,13 +508,13 @@ void Toolbar::add(int action, bool doclean)
 }
 
 
-void Toolbar::add(LString const & func, bool doclean)
+void Toolbar::add(string const & func, bool doclean)
 {
        int tf = lyxaction.LookupFunc(func.c_str());
 
        if (tf == -1){
-               lyxerr.print("Toolbar::add: no LyX command called`"
-                               +func+"'exists!")
+               lyxerr << "Toolbar::add: no LyX command called`"
+                      << func << "'exists!" << endl
        } else {
                add(tf, doclean);
        }
@@ -514,7 +523,7 @@ void Toolbar::add(LString const & func, bool doclean)
 
 void Toolbar::clean()
 {
-       toolbarItem *item, *tmp= NULL;
+       toolbarItem *item, *tmp= 0;
        item = toollist;
 
        reset();
@@ -527,22 +536,22 @@ void Toolbar::clean()
                delete item;
                item = tmp;
        }
-       //lyxerr.print(LString("Combox: ") + int(combox));
+       lyxerr[Debug::TOOLBAR] << "Combox: " << combox << endl;
        if (combox) {
                delete combox;
                combox = 0;
        }
        if (owner)
                fl_unfreeze_form(owner->getForm());
-       lyxerr.debug("toolbar cleaned",Error::TOOLBAR);
+       lyxerr[Debug::TOOLBAR] << "toolbar cleaned" << endl;
        cleaned = true;
 }
 
 
 void Toolbar::push(int nth)
 {
-       lyxerr.debug(LString("Toolbar::push: trying to trigger no `")+nth+'\'',
-                     Error::TOOLBAR);
+       lyxerr[Debug::TOOLBAR] << "Toolbar::push: trying to trigger no `"
+                              << nth << '\'' << endl;
        
        if (nth == 0) return;
 
@@ -565,29 +574,30 @@ void Toolbar::read(LyXLex &lex)
 {
        //consistency check
        if (lex.GetString() != "\\begin_toolbar")
-               lyxerr.print("Toolbar::read: ERROR wrong token:`"
-                               +lex.GetString()+'\''); 
+               lyxerr << "Toolbar::read: ERROR wrong token:`"
+                      << lex.GetString() << '\'' << endl;
 
        clean();
-       LString func;
+       string func;
        bool quit = false;
        
        lex.pushTable(toolTags, TO_LAST - 1);
 
-       if (lyxerr.debugging(Error::LEX_PARSER))
+       if (lyxerr.debugging(Debug::PARSER))
                lex.printTable();
        
        while (lex.IsOK() && !quit) {
                
-               lyxerr.debug("Toolbar::read: current lex text: `"
-                               +lex.GetString()+'\'',Error::TOOLBAR);
+               lyxerr[Debug::TOOLBAR] << "Toolbar::read: current lex text: `"
+                                      << lex.GetString() << '\'' << endl;
 
                switch(lex.lex()) {
                  case TO_ADD:
                          if (lex.EatLine()) {
                                  func = lex.GetString();
-                                 lyxerr.debug("Toolbar::read TO_ADD func: `"
-                                              + func + "'", Error::TOOLBAR);
+                                 lyxerr[Debug::TOOLBAR]
+                                         << "Toolbar::read TO_ADD func: `"
+                                         << func << "'" << endl;
                                  add(func);
                          }
                          break;