#include <config.h>
// Too hard to make concept checks work with this file
+#ifdef _GLIBCXX_CONCEPT_CHECKS
+#undef _GLIBCXX_CONCEPT_CHECKS
+#endif
#ifdef _GLIBCPP_CONCEPT_CHECKS
#undef _GLIBCPP_CONCEPT_CHECKS
#endif
#include "GtkmmX.h"
#include "GLyXKeySym.h"
+#include "BufferView.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
+#include "WorkArea.h"
+#include "Gui.h"
+#include "Selection.h"
using boost::shared_ptr;
GWorkArea::GWorkArea(LyXView & owner, int width, int height)
- : workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this)
+ : view_(owner), workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this),
+ adjusting_(false)
{
workArea_.set_size_request(width, height);
workArea_.set_double_buffered(false);
gtk_im_context_set_client_window(
imContext_, workArea_.get_window()->gobj());
}
- workAreaResize();
+ view_.workArea()->resizeBufferView();
return true;
}
void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
{
+ if (adjusting_)
+ return;
+
+ adjusting_ = true;
+
Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
adjustment->set_lower(0);
int workAreaHeight = workHeight();
adjustment->set_page_size(workAreaHeight);
adjustment->set_value(0);
adjustment->changed();
+ adjusting_ = false;
return;
}
- adjustment->set_step_increment(line_height);
+ adjustment->set_step_increment(line_height * 3);
adjustment->set_page_increment(workAreaHeight - line_height);
// Allow the user half a screen of blank at the end
// to make scrollbar consistant with centering the cursor
- adjustment->set_upper(height + workAreaHeight / 2);
+ adjustment->set_upper(height + workAreaHeight / 4);
adjustment->set_page_size(workAreaHeight);
adjustment->set_value(pos);
adjustment->changed();
+ adjusting_ = false;
}
void GWorkArea::onScroll()
{
+ if (adjusting_)
+ return;
+
+ adjusting_ = true;
+
double val = vscrollbar_.get_adjustment()->get_value();
- scrollDocView(static_cast<int>(val));
+ view_.workArea()->scrollBufferView(static_cast<int>(val));
+ adjusting_ = false;
}
default:
break;
}
- dispatch(FuncRequest(ka,
+ view_.workArea()->dispatch(FuncRequest(ka,
static_cast<int>(event->x),
static_cast<int>(event->y),
gButtonToLyx(event->button)));
bool GWorkArea::onButtonRelease(GdkEventButton * event)
{
- dispatch(FuncRequest(LFUN_MOUSE_RELEASE,
+ view_.workArea()->dispatch(FuncRequest(LFUN_MOUSE_RELEASE,
static_cast<int>(event->x),
static_cast<int>(event->y),
gButtonToLyx(event->button)));
}
timeBefore = event->time;
}
- dispatch(FuncRequest(LFUN_MOUSE_MOTION,
+ view_.workArea()->dispatch(FuncRequest(LFUN_MOUSE_MOTION,
static_cast<int>(event->x),
static_cast<int>(event->y),
gtkButtonState(event->state)));
bool GWorkArea::onKeyPress(GdkEventKey * event)
{
-#ifdef I18N
- inputCache_ = "";
- bool inputGet = gtk_im_context_filter_keypress(imContext_, event);
- // cope with ascii
- if ((inputGet && inputCache_.size() == 1 && inputCache_[0] < 128) ||
- !inputGet) {
-#endif
+// #ifdef I18N
+// inputCache_ = "";
+// bool inputGet = gtk_im_context_filter_keypress(imContext_, event);
+// // cope with ascii
+// if ((inputGet && inputCache_.size() == 1 && inputCache_[0] < 128) ||
+// !inputGet) {
+// #endif
GLyXKeySym *glk = new GLyXKeySym(event->keyval);
- workAreaKeyPress(LyXKeySymPtr(glk),
- gtkKeyState(event->state));
-#ifdef I18N
- } else if (!inputCache_.empty())
- workAreaCJK_IMprocess(inputCache_.size(), inputCache_.data());
-#endif
+ view_.workArea()->processKeySym(LyXKeySymPtr(glk),
+ gtkKeyState(event->state));
+// #ifdef I18N
+// } else if (!inputCache_.empty())
+// workAreaCJK_IMprocess(inputCache_.size(), inputCache_.data());
+// #endif
return true;
}
-
-void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
- guint /*info*/)
-{
- selectionRequested();
-}
-
-
-void GWorkArea::onClipboardClear()
-{
-// selectionLost();
-}
-
-
-void GWorkArea::haveSelection(bool toHave) const
-{
- if (toHave) {
- Glib::RefPtr<Gtk::Clipboard> clipboard =
- Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
- std::vector<Gtk::TargetEntry> listTargets;
- listTargets.push_back(Gtk::TargetEntry("UTF8_STRING"));
- clipboard->set(listTargets,
- sigc::mem_fun(const_cast<GWorkArea&>(*this),
- &GWorkArea::onClipboardGet),
- sigc::mem_fun(const_cast<GWorkArea&>(*this),
- &GWorkArea::onClipboardClear));
- }
-}
-
-
-string const GWorkArea::getClipboard() const
-{
- Glib::RefPtr<Gtk::Clipboard> clipboard =
- Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
- return Glib::locale_from_utf8(clipboard->wait_for_text());
-}
-
-
-void GWorkArea::putClipboard(string const & str) const
-{
- Glib::RefPtr<Gtk::Clipboard> clipboard =
- Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
- clipboard->set_text(Glib::locale_to_utf8(str));
-}
-
} // namespace frontend
} // namespace lyx