#include <boost/bind.hpp>
-using lyx::frontend::Box;
-using lyx::frontend::BoxList;
-using lyx::frontend::WidgetMap;
+using boost::shared_ptr;
using std::abs;
using std::dec;
using std::hex;
using std::string;
+namespace lyx {
+namespace frontend {
namespace {
// Hand control of the layout of these widgets to the
// Layout Engine.
XFormsView & xview = dynamic_cast<XFormsView &>(owner);
- BoxList & boxlist = xview.getBox(XFormsView::Center).children();
+ BoxList & boxlist = xview.getBox(XFormsView::Center)->children();
- wa_box_ = &boxlist.push_back(Box(0,0));
+ wa_box_ = boxlist.push_back(Box(0,0));
wa_box_->set(Box::Horizontal);
- Box & frame_box = widgets_.add(frame, wa_box_->children(), 0, 0);
- frame_box.set(Box::Expand);
+ shared_ptr<Box> frame_box = widgets_.add(frame, wa_box_->children(), 0, 0);
+ frame_box->set(Box::Expand);
int const bw = int(abs(fl_get_border_width()));
- Box & wa_box = embed(work_area, frame_box.children(), widgets_, bw);
- wa_box.set(Box::Expand);
+ shared_ptr<Box> wa_box = embed(work_area, frame_box->children(), widgets_, bw);
+ wa_box->set(Box::Expand);
widgets_.add(scrollbar, wa_box_->children(), 17, 0);
FL_Coord, FL_Coord,
int key, void * xev)
{
+ if (event != 11)
+ lyxerr[Debug::WORKAREA] << "Workarea event: EVENT: " << event << endl;
+
XEvent * ev = static_cast<XEvent*>(xev);
XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
case FL_PUSH:
if (!ev || ev->xbutton.button == 0) break;
+
+ if (ev->xbutton.button == 4 || ev->xbutton.button == 5) {
+ static long last_wheel;
+
+ long cur_wheel = ev->xbutton.time;
+ if (last_wheel == cur_wheel)
+ break;
+
+ last_wheel = cur_wheel;
+
+ float l, r;
+ fl_get_scrollbar_increment(area->scrollbar, &l, &r);
+
+ if (ev->xbutton.button == 4)
+ l *= -1.0;
+
+ fl_set_scrollbar_value(
+ area->scrollbar,
+ fl_get_scrollbar_value(area->scrollbar) + l);
+
+ area->scroll_cb();
+ break;
+ }
+
// Should really have used xbutton.state
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
area->dispatch(
case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state
+
+ if (ev->xbutton.button == 4 || ev->xbutton.button == 5) {
+ // We ingnore wheel event here
+ break;
+ }
+
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
+
area->dispatch(
FuncRequest(LFUN_MOUSE_RELEASE,
ev->xbutton.x - ob->x,
break;
case FL_DRAG: {
+ lyxerr[Debug::WORKAREA] << "Workarea event: DRAG 0" << endl;
+
if (!ev || !area->scrollbar)
break;
case FL_DBLCLICK:
if (ev) {
+ if (ev->xbutton.button == 4 || ev->xbutton.button == 5) {
+ // Ignore wheel events
+ break;
+ }
+
+
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
ev->xbutton.x - ob->x,
case FL_TRPLCLICK:
if (ev) {
+ if (ev->xbutton.button == 4 || ev->xbutton.button == 5) {
+ // Ignore wheel events
+ break;
+ }
+
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
ev->xbutton.x - ob->x,
fl_stuff_clipboard(work_area, 0, hold.data(), hold.size(), 0);
}
+
+} // namespace frontend
+} // namespace lyx