WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
- : owner(o), workareapixmap(0), painter_(*this)
+ : owner_(o), workareapixmap(0), painter_(*this)
{
fl_freeze_all_forms();
// If we really want the accellerating scroll we can do that
// from here. IMHO that is a waste of effort since we already
// have other ways to move fast around in the document. (Lgb)
- area->owner->scrollCB(fl_get_scrollbar_value(ob));
+ area->owner_->scrollCB(fl_get_scrollbar_value(ob));
waitForX();
}
if (!area) return 1;
- switch (event){
+ switch (event){
case FL_DRAW:
if (!area->work_area ||
!area->work_area->form->visible)
lyxerr.debug() << "Workarea event: DRAW" << endl;
area->createPixmap(area->workWidth(), area->height());
Lgb_bug_find_hack = true;
- area->owner->workAreaExpose();
+ //workAreaExpose();
+ area->owner_->workAreaExpose();
Lgb_bug_find_hack = false;
break;
case FL_PUSH:
if (!ev) break;
// Should really have used xbutton.state
lyxerr.debug() << "Workarea event: PUSH" << endl;
- area->owner->workAreaButtonPress(ev->xbutton.x - ob->x,
+ //workAreaButtonPress(ev->xbutton.x - ob->x,
+ // ev->xbutton.y - ob->y,
+ // ev->xbutton.button);
+
+ area->owner_->workAreaButtonPress(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
ev->xbutton.button);
break;
if (!ev) break;
// Should really have used xbutton.state
lyxerr.debug() << "Workarea event: RELEASE" << endl;
- area->owner->workAreaButtonRelease(ev->xbutton.x - ob->x,
+ //workAreaButtonRelease(ev->xbutton.x - ob->x,
+ // ev->xbutton.y - ob->y,
+ // ev->xbutton.button);
+ area->owner_->workAreaButtonRelease(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
ev->xbutton.button);
break;
fl_get_scrollbar_value(area->scrollbar) != scrollbar_value_old
) {
lyxerr.debug() << "Workarea event: MOUSE" << endl;
- area->owner->workAreaMotionNotify(ev->xmotion.x - ob->x,
+ //workAreaMotionNotify(ev->xmotion.x - ob->x,
+ // ev->xmotion.y - ob->y,
+ // ev->xbutton.state);
+
+ area->owner_->workAreaMotionNotify(ev->xmotion.x - ob->x,
ev->xmotion.y - ob->y,
ev->xbutton.state);
}
// case FL_KEYBOARD: WorkAreaKeyPress(ob, 0,0,0,ev,0); break;
case FL_FOCUS:
lyxerr.debug() << "Workarea event: FOCUS" << endl;
+ //workAreaFocus();
break;
case FL_UNFOCUS:
lyxerr.debug() << "Workarea event: UNFOCUS" << endl;
+ //workAreaUnfocus();
break;
case FL_ENTER:
lyxerr.debug() << "Workarea event: ENTER" << endl;
- area->owner->enterView();
+ //workAreaEnter();
+ area->owner_->enterView();
break;
case FL_LEAVE:
lyxerr.debug() << "Workarea event: LEAVE" << endl;
- area->owner->leaveView();
+ //workAreaLeave();
+ area->owner_->leaveView();
break;
case FL_DBLCLICK:
if (!ev) break;
lyxerr.debug() << "Workarea event: DBLCLICK" << endl;
- area->owner->doubleClick(ev->xbutton.x - ob->x,
+ //workAreaDoubleClick(ev->xbutton.x - ob->x,
+ // ev->xbutton.y - ob->y,
+ // ev->xbutton.button);
+ area->owner_->doubleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
ev->xbutton.button);
break;
case FL_TRPLCLICK:
if (!ev) break;
lyxerr.debug() << "Workarea event: TRPLCLICK" << endl;
- area->owner->tripleClick(ev->xbutton.x - ob->x,
+ //workAreaTripleClick(ev->xbutton.x - ob->x,
+ // ev->xbutton.y - ob->y,
+ // ev->xbutton.button);
+ area->owner_->tripleClick(ev->xbutton.x - ob->x,
ev->xbutton.y - ob->y,
ev->xbutton.button);
break;
case FL_OTHER:
if (!ev) break;
- if (ev->type == SelectionNotify) {
- lyxerr.debug() << "Workarea event: SELECTION" << endl;
- area->owner->workAreaSelectionNotify(area->work_area->form->window, ev);
- } else
lyxerr.debug() << "Workarea event: OTHER" << endl;
break;
return 1;
}
+
+
+static string clipboard_selection;
+static bool clipboard_read = false;
+
+extern "C" {
+ static
+int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/,
+ void const * data, long size)
+{
+ clipboard_selection.erase();
+ if (size == 0) return 0; // no selection
+
+ clipboard_selection.reserve(size);
+ for (int i = 0; i < size; ++i) {
+ clipboard_selection += static_cast<char const *>(data)[i];
+ }
+ clipboard_read = true;
+ return 0;
+}
+}
+
+string WorkArea::getClipboard() const
+{
+ clipboard_read = false;
+
+ if (fl_request_clipboard(work_area, 0, request_clipboard_cb) == -1)
+ return string();
+
+ XEvent ev;
+
+ while (!clipboard_read) {
+ if (fl_check_forms() == FL_EVENT) {
+ lyxerr << "LyX: This shouldn't happen..." << endl;
+ fl_XNextEvent(&ev);
+ }
+ }
+ return clipboard_selection;
+}
+
+
+void WorkArea::putClipboard(string const & s) const
+{
+ static string hold;
+ hold = s;
+
+ fl_stuff_clipboard(work_area, 0, hold.c_str(), hold.size(), 0);
+}