X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.C;h=a9abd9ff9cc6112a7fc83383395c17a3d6888347;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=212a1831bb014cc3524daf5c438b3570a7986f9c;hpb=0eccdd1c3613e5170deb77b22174dd0afde833e9;p=lyx.git diff --git a/src/BufferView.C b/src/BufferView.C index 212a1831bb..a9abd9ff9c 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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,9 +415,9 @@ 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 = (void*) this; /* This is how we pass the BufferView + obj->u_vdata = this; /* This is how we pass the BufferView to the work_area_handler. */ fl_set_object_boxtype(obj,FL_DOWN_BOX); fl_set_object_resize(obj, FL_RESIZE_ALL); @@ -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,8 +491,8 @@ 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); - obj->u_vdata = (void*) this; + fl_set_object_callback(obj,C_BufferView_CursorToggleCB,0); + obj->u_vdata = this; } @@ -893,18 +916,6 @@ int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, // Hit above or below the table? if (doit) { -#if 0 - long y_tmp = y + screen->first; - - Row* row = _buffer->text->GetRowNearY(y_tmp); - - // Isn't this empty code anyway? (Lgb) - if (row->par != _buffer->text->cursor.par) - doit = true; - } - - if (doit) { -#endif if (!_buffer->text->selection) { screen->ToggleSelection(); _buffer->text->ClearSelection(); @@ -954,18 +965,6 @@ int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, // Right click on a footnote flag opens float menu if (button == 3) { -#if 0 - // Isn't this empty code anyway? (Lgb) - if (_buffer->text->cursor.par->footnoteflag == - LyXParagraph::OPEN_FOOTNOTE) { - selection_possible = false; - lyxerr.debug("LyX: Sorry not implemented yet."); - return 0; - } - } - - if (button == 3) { -#endif selection_possible = false; return 0; } @@ -1352,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; @@ -1515,6 +1514,8 @@ void BufferView::savePosition() void BufferView::restorePosition() { + if (backstack->empty()) return; + int x, y; string fname = backstack->pop(&x, &y); @@ -1525,4 +1526,3 @@ void BufferView::restorePosition() currentBuffer()->text->SetCursorFromCoordinates(x, y); currentBuffer()->update(0); } -