]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / BufferView.C
index 43761f4c4d04503240601be89db00896f0d5dfa5..a9abd9ff9cc6112a7fc83383395c17a3d6888347 100644 (file)
@@ -33,7 +33,7 @@
 #include "lyxscreen.h"
 #include "up.xpm"
 #include "down.xpm"
-#include "error.h"
+#include "debug.h"
 #include "lyxdraw.h"
 #include "lyx_gui_misc.h"
 #include "BackStack.h"
@@ -90,7 +90,7 @@ BufferView::~BufferView()
 
 void BufferView::setBuffer(Buffer *b)
 {
-       lyxerr.debug("Setting buffer in BufferView");
+       lyxerr.debug() << "Setting buffer in BufferView" << endl;
        if (_buffer) {
                _buffer->InsetSleep();
                _buffer->delUser(this);
@@ -112,7 +112,7 @@ void BufferView::setBuffer(Buffer *b)
        }
 
        if (_buffer) {
-               lyxerr.debug(string("  Buffer addr: ") + tostr(_buffer));
+               lyxerr.debug() << "  Buffer addr: " << _buffer << endl;
                _buffer->addUser(this);
                _owner->getMenus()->showMenus();
                // If we don't have a text object for this, we make one
@@ -127,7 +127,7 @@ void BufferView::setBuffer(Buffer *b)
                updateAllVisibleBufferRelatedPopups();
                _buffer->InsetWakeup();
        } else {
-               lyxerr.debug("  No Buffer!");
+               lyxerr.debug() << "  No Buffer!" << endl;
                _owner->getMenus()->hideMenus();
                //workAreaExpose();
                updateScrollbar();
@@ -166,7 +166,7 @@ static bool lgb_hack = false;
 
 void BufferView::redraw()
 {
-       lyxerr.debug("BufferView::redraw()");
+       lyxerr.debug() << "BufferView::redraw()" << endl;
        lgb_hack = true;
        fl_redraw_object(work_area);
        fl_redraw_object(scrollbar);
@@ -255,7 +255,7 @@ void BufferView::updateScrollbar()
 
 void BufferView::redoCurrentBuffer()
 {
-       lyxerr.debug("BufferView::redoCurrentBuffer");
+       lyxerr.debug() << "BufferView::redoCurrentBuffer" << endl;
        if (_buffer && _buffer->text) {
                resize();
                _owner->updateLayoutChoice();
@@ -265,7 +265,7 @@ void BufferView::redoCurrentBuffer()
 
 int BufferView::resizeCurrentBuffer()
 {
-       lyxerr.debug("resizeCurrentBuffer");
+       lyxerr.debug() << "resizeCurrentBuffer" << endl;
        
        LyXParagraph *par = 0;
        LyXParagraph *selstartpar = 0;
@@ -364,6 +364,29 @@ void BufferView::gotoError()
                _buffer->text->cursor;
 }
 
+// Just a bunch of C wrappers around static members of BufferView
+extern "C" void C_BufferView_UpCB(FL_OBJECT *ob, long buf) {
+       BufferView::UpCB(ob,buf);
+}
+
+extern "C" void C_BufferView_DownCB(FL_OBJECT *ob, long buf) {
+       BufferView::DownCB(ob,buf);
+}
+
+extern "C" void C_BufferView_ScrollCB(FL_OBJECT *ob, long buf) {
+       BufferView::ScrollCB(ob,buf);
+}
+
+extern "C" void C_BufferView_CursorToggleCB(FL_OBJECT *ob, long buf) {
+       BufferView::CursorToggleCB(ob,buf);
+}
+
+extern "C" int C_BufferView_work_area_handler(FL_OBJECT *ob, int event,
+                                             FL_Coord, FL_Coord, 
+                                             int key, void *xev) {
+       return BufferView::work_area_handler(ob, event, 0, 0, key, xev);
+}
+
 
 void BufferView::create_view(int xpos, int ypos, int width, int height)
 {
@@ -392,7 +415,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
                                      xpos +bw, ypos+bw,
                                      width-15-2*bw /* scrollbarwidth */,
                                      height-2*bw,"",
-                                     work_area_handler);
+                                     C_BufferView_work_area_handler);
        obj->wantkey = FL_KEY_TAB;
        obj->u_vdata = this; /* This is how we pass the BufferView
                                       to the work_area_handler. */
@@ -418,7 +441,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        fl_set_object_color(obj,FL_MCOL,FL_BLUE);
        fl_set_object_resize(obj, FL_RESIZE_ALL);
        fl_set_object_gravity(obj,NorthEastGravity, NorthEastGravity);
-       fl_set_object_callback(obj,UpCB,(long)this);
+       fl_set_object_callback(obj,C_BufferView_UpCB,(long)this);
        fl_set_pixmapbutton_data(obj, up_xpm);
 
 #if FL_REVISION >85
@@ -436,7 +459,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        fl_set_object_boxtype(obj, FL_UP_BOX);
        fl_set_object_resize(obj, FL_RESIZE_ALL);
        fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity);
-       fl_set_object_callback(obj,ScrollCB,(long)this);
+       fl_set_object_callback(obj,C_BufferView_ScrollCB,(long)this);
        
        // down - scrollbar button
 #if FL_REVISION > 85
@@ -452,7 +475,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        fl_set_object_color(obj,FL_MCOL,FL_BLUE);
        fl_set_object_resize(obj, FL_RESIZE_ALL);
        fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity);
-       fl_set_object_callback(obj,DownCB,(long)this);
+       fl_set_object_callback(obj,C_BufferView_DownCB,(long)this);
        fl_set_pixmapbutton_data(obj, down_xpm);
        fl_set_border_width(-bw);
 
@@ -468,7 +491,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height)
        // timer_cursor
        timer_cursor = obj = fl_add_timer(FL_HIDDEN_TIMER,
                                          0,0,0,0,"Timer");
-       fl_set_object_callback(obj,CursorToggleCB,0);
+       fl_set_object_callback(obj,C_BufferView_CursorToggleCB,0);
        obj->u_vdata = this;
 }
 
@@ -1328,13 +1351,13 @@ void BufferView::CursorToggleCB(FL_OBJECT *ob, long)
                Window tmpwin;
                int tmp;
                XGetInputFocus(fl_display, &tmpwin, &tmp);
-               lyxerr.debug(string("tmpwin: ") + tostr(tmpwin));
-               lyxerr.debug(string("window: ")
-                            + tostr(view->_owner->getForm()->window));
-               lyxerr.debug(string("work_area_focus: ")
-                            + tostr(view->work_area_focus));
-               lyxerr.debug(string("lyx_focus      : ")
-                            + tostr(view->lyx_focus));
+               if (lyxerr.debugging()) {
+                       lyxerr << "tmpwin: " << tmpwin
+                              << "\nwindow: " << view->_owner->getForm()->window
+                              << "\nwork_area_focus: " << view->work_area_focus
+                              << "\nlyx_focus      : " << view->lyx_focus
+                              << endl;
+               }
                if (tmpwin != view->_owner->getForm()->window) {
                        view->lyx_focus = false;
                        goto skip_timer;
@@ -1491,6 +1514,8 @@ void BufferView::savePosition()
 
 void BufferView::restorePosition()
 {
+       if (backstack->empty()) return;
+       
        int  x, y;
        string fname = backstack->pop(&x, &y);