2003-09-02 10:29:05 +00:00
|
|
|
/**
|
|
|
|
* \file GWorkArea.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
2003-09-02 17:02:32 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-09-02 10:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GWorkArea.h"
|
|
|
|
#include "GView.h"
|
|
|
|
#include "GtkmmX.h"
|
|
|
|
#include "GLyXKeySym.h"
|
|
|
|
|
2003-09-15 15:20:22 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "funcrequest.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
|
2004-09-27 19:04:17 +00:00
|
|
|
using boost::shared_ptr;
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2004-11-04 21:50:10 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
mouse_button::state gButtonToLyx(guint gdkbutton)
|
|
|
|
{
|
|
|
|
// GDK uses int 1,2,3 but lyx uses enums (1,2,4)
|
|
|
|
switch (gdkbutton) {
|
|
|
|
case 1:
|
|
|
|
return mouse_button::button1;
|
|
|
|
case 2:
|
|
|
|
return mouse_button::button2;
|
|
|
|
case 3:
|
|
|
|
return mouse_button::button3;
|
|
|
|
case 4:
|
|
|
|
return mouse_button::button4;
|
|
|
|
case 5:
|
|
|
|
return mouse_button::button5;
|
|
|
|
}
|
2004-11-14 17:10:04 +00:00
|
|
|
|
2004-11-04 21:50:10 +00:00
|
|
|
// This shouldn't happen, according to gdk docs
|
|
|
|
lyxerr << "gButtonToLyx: unhandled button index\n";
|
|
|
|
return mouse_button::button1;
|
|
|
|
}
|
2003-09-02 10:29:05 +00:00
|
|
|
|
2004-11-04 21:50:10 +00:00
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
ColorCache colorCache;
|
2003-09-02 10:29:05 +00:00
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
Gdk::Color * ColorCache::getColor(LColor_color clr)
|
2003-09-16 07:53:02 +00:00
|
|
|
{
|
|
|
|
MapIt it = cache_.find(clr);
|
2004-09-27 19:04:17 +00:00
|
|
|
return it == cache_.end() ? 0 : it->second.get();
|
2003-09-16 07:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
XftColor * ColorCache::getXftColor(LColor_color clr)
|
2003-09-16 07:53:02 +00:00
|
|
|
{
|
|
|
|
MapIt2 it = cache2_.find(clr);
|
2004-09-27 19:04:17 +00:00
|
|
|
return it == cache2_.end() ? 0 : it->second.get();
|
2003-09-16 07:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
void ColorCache::cacheColor(LColor_color clr, Gdk::Color * gclr)
|
2003-09-16 07:53:02 +00:00
|
|
|
{
|
2004-09-27 19:04:17 +00:00
|
|
|
cache_[clr] = shared_ptr<Gdk::Color>(gclr);
|
2003-09-16 07:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
void ColorCache::cacheXftColor(LColor_color clr, XftColor * xclr)
|
2003-09-16 07:53:02 +00:00
|
|
|
{
|
2004-09-27 19:04:17 +00:00
|
|
|
cache2_[clr] = shared_ptr<XftColor>(xclr);
|
2003-09-16 07:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
void ColorCache::clear()
|
|
|
|
{
|
|
|
|
cache_.clear();
|
|
|
|
cache2_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
XftColor * ColorHandler::getXftColor(LColor_color clr)
|
2003-09-02 10:29:05 +00:00
|
|
|
{
|
|
|
|
XftColor * xclr = colorCache.getXftColor(clr);
|
|
|
|
if (!xclr) {
|
|
|
|
xclr = new XftColor;
|
|
|
|
Colormap colormap = GDK_COLORMAP_XCOLORMAP(
|
|
|
|
owner_.getColormap()->gobj());
|
|
|
|
Visual * visual = GDK_VISUAL_XVISUAL(
|
|
|
|
owner_.getColormap()->get_visual()->gobj());
|
|
|
|
XftColorAllocName(owner_.getDisplay(), visual, colormap,
|
2003-10-28 16:45:09 +00:00
|
|
|
const_cast<char*>(
|
|
|
|
lcolor.getX11Name(clr).c_str())
|
|
|
|
, xclr);
|
2003-09-02 10:29:05 +00:00
|
|
|
colorCache.cacheXftColor(clr, xclr);
|
|
|
|
}
|
|
|
|
return xclr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
Gdk::Color * ColorHandler::getGdkColor(LColor_color clr)
|
2003-09-02 10:29:05 +00:00
|
|
|
{
|
|
|
|
Gdk::Color * gclr = colorCache.getColor(clr);
|
|
|
|
if (!gclr) {
|
|
|
|
gclr = new Gdk::Color;
|
|
|
|
gclr->parse(lcolor.getX11Name(clr));
|
|
|
|
owner_.getColormap()->alloc_color(*gclr);
|
|
|
|
colorCache.cacheColor(clr, gclr);
|
|
|
|
}
|
|
|
|
return gclr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
mouse_button::state gtkButtonState(unsigned int state)
|
|
|
|
{
|
|
|
|
mouse_button::state b = mouse_button::none;
|
|
|
|
if (state & GDK_BUTTON1_MASK)
|
|
|
|
b = mouse_button::button1;
|
|
|
|
else if (state & GDK_BUTTON2_MASK)
|
|
|
|
b = mouse_button::button2;
|
|
|
|
else if (state & GDK_BUTTON3_MASK)
|
|
|
|
b = mouse_button::button3;
|
|
|
|
else if (state & GDK_BUTTON3_MASK)
|
|
|
|
b = mouse_button::button3;
|
|
|
|
else if (state & GDK_BUTTON4_MASK)
|
|
|
|
b = mouse_button::button4;
|
|
|
|
else if (state & GDK_BUTTON5_MASK)
|
|
|
|
b = mouse_button::button5;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
key_modifier::state gtkKeyState(guint state)
|
|
|
|
{
|
|
|
|
key_modifier::state k = key_modifier::none;
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
|
|
|
k |= key_modifier::ctrl;
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
k |= key_modifier::shift;
|
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
k |= key_modifier::alt;
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void inputCommitRelay(GtkIMContext */*imcontext*/, gchar * str, GWorkArea * area)
|
|
|
|
{
|
|
|
|
area->inputCommit(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-28 11:33:27 +00:00
|
|
|
GWorkArea::GWorkArea(LyXView & owner, int width, int height)
|
2003-09-02 10:29:05 +00:00
|
|
|
: workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this)
|
|
|
|
{
|
|
|
|
workArea_.set_size_request(width, height);
|
|
|
|
workArea_.set_double_buffered(false);
|
|
|
|
workArea_.add_events(Gdk::STRUCTURE_MASK | Gdk::EXPOSURE_MASK |
|
|
|
|
Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK |
|
|
|
|
Gdk::KEY_PRESS_MASK | Gdk::BUTTON1_MOTION_MASK);
|
|
|
|
workArea_.signal_expose_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onExpose));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.signal_configure_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onConfigure));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.signal_button_press_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onButtonPress));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.signal_button_release_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onButtonRelease));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.signal_key_press_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onKeyPress));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.signal_motion_notify_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onMotionNotify));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.show();
|
|
|
|
vscrollbar_.get_adjustment()->signal_value_changed().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onScroll));
|
2004-09-24 06:32:22 +00:00
|
|
|
workArea_.signal_scroll_event().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GWorkArea::onScrollWheel));
|
2003-09-02 10:29:05 +00:00
|
|
|
vscrollbar_.show();
|
|
|
|
hbox_.children().push_back(Gtk::Box_Helpers::Element(workArea_));
|
|
|
|
hbox_.children().push_back(
|
|
|
|
Gtk::Box_Helpers::Element(vscrollbar_,Gtk::PACK_SHRINK));
|
|
|
|
hbox_.show();
|
2004-04-27 14:48:13 +00:00
|
|
|
|
2004-04-28 11:33:27 +00:00
|
|
|
GView & gview = static_cast<GView &>(owner);
|
|
|
|
gview.getBox(GView::Center).children().push_back(
|
2003-09-02 10:29:05 +00:00
|
|
|
Gtk::Box_Helpers::Element(hbox_));
|
2004-04-27 14:48:13 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.set_flags(workArea_.get_flags() | Gtk::CAN_DEFAULT |
|
|
|
|
Gtk::CAN_FOCUS);
|
|
|
|
workArea_.grab_default();
|
2004-04-28 11:33:27 +00:00
|
|
|
gview.setGWorkArea(&workArea_);
|
2003-09-02 10:29:05 +00:00
|
|
|
imContext_ = GTK_IM_CONTEXT(gtk_im_multicontext_new());
|
|
|
|
g_signal_connect(G_OBJECT(imContext_), "commit",
|
|
|
|
G_CALLBACK(&inputCommitRelay),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GWorkArea::~GWorkArea()
|
|
|
|
{
|
|
|
|
g_object_unref(imContext_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-16 07:53:02 +00:00
|
|
|
Painter & GWorkArea::getPainter()
|
|
|
|
{
|
|
|
|
return painter_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GWorkArea::workWidth() const
|
|
|
|
{
|
|
|
|
return workArea_.get_width();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GWorkArea::workHeight() const
|
|
|
|
{
|
|
|
|
return workArea_.get_height();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GWorkArea::xpos() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GWorkArea::ypos() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::Window> GWorkArea::getWindow()
|
|
|
|
{
|
|
|
|
return workArea_.get_window();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Display * GWorkArea::getDisplay() const
|
|
|
|
{
|
|
|
|
return GDK_WINDOW_XDISPLAY(
|
|
|
|
const_cast<GdkWindow*>(workArea_.get_window()->gobj()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::Pixmap> GWorkArea::getPixmap()
|
|
|
|
{
|
|
|
|
return workAreaPixmap_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::GC> GWorkArea::getGC()
|
|
|
|
{
|
|
|
|
return workAreaGC_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::Colormap> GWorkArea::getColormap()
|
|
|
|
{
|
|
|
|
return workArea_.get_colormap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XftDraw * GWorkArea::getXftDraw()
|
|
|
|
{
|
|
|
|
return draw_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ColorHandler & GWorkArea::getColorHandler()
|
|
|
|
{
|
|
|
|
return colorHandler_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
bool GWorkArea::onExpose(GdkEventExpose * event)
|
|
|
|
{
|
|
|
|
workArea_.get_window()->draw_drawable(
|
|
|
|
workArea_.get_style()->get_black_gc(),
|
|
|
|
workAreaPixmap_,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.width, event->area.height);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GWorkArea::onConfigure(GdkEventConfigure * /*event*/)
|
|
|
|
{
|
|
|
|
int x, y, width, height, depth;
|
|
|
|
workArea_.get_window()->get_geometry(x, y, width, height, depth);
|
|
|
|
if (draw_)
|
|
|
|
XftDrawDestroy(draw_);
|
|
|
|
workAreaPixmap_ = Gdk::Pixmap::create(workArea_.get_window(),
|
|
|
|
width, height, depth);
|
|
|
|
Pixmap pixmap = GDK_PIXMAP_XID(workAreaPixmap_->gobj());
|
|
|
|
Colormap colormap = GDK_COLORMAP_XCOLORMAP(
|
|
|
|
workArea_.get_colormap()->gobj());
|
|
|
|
Visual * visual = GDK_VISUAL_XVISUAL(
|
|
|
|
workArea_.get_colormap()->get_visual()->gobj());
|
|
|
|
draw_ = XftDrawCreate(getDisplay(), pixmap,
|
|
|
|
visual, colormap);
|
|
|
|
if (!workAreaGC_) {
|
|
|
|
workAreaGC_ = Gdk::GC::create(workArea_.get_window());
|
|
|
|
Gdk::Cursor cursor(Gdk::XTERM);
|
|
|
|
workArea_.get_window()->set_cursor(cursor);
|
|
|
|
gtk_im_context_set_client_window(
|
|
|
|
imContext_, workArea_.get_window()->gobj());
|
|
|
|
}
|
|
|
|
workAreaResize();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
|
|
|
|
{
|
|
|
|
Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
|
|
|
|
adjustment->set_lower(0);
|
|
|
|
int workAreaHeight = workHeight();
|
|
|
|
if (!height || height < workAreaHeight) {
|
|
|
|
adjustment->set_upper(workAreaHeight);
|
|
|
|
adjustment->set_page_size(workAreaHeight);
|
|
|
|
adjustment->set_value(0);
|
|
|
|
adjustment->changed();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
adjustment->set_step_increment(line_height);
|
|
|
|
adjustment->set_page_increment(workAreaHeight - line_height);
|
2004-10-11 16:58:17 +00:00
|
|
|
// 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);
|
2003-09-02 10:29:05 +00:00
|
|
|
adjustment->set_page_size(workAreaHeight);
|
|
|
|
adjustment->set_value(pos);
|
|
|
|
adjustment->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GWorkArea::onScroll()
|
|
|
|
{
|
|
|
|
double val = vscrollbar_.get_adjustment()->get_value();
|
|
|
|
scrollDocView(static_cast<int>(val));
|
|
|
|
}
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 06:32:22 +00:00
|
|
|
bool GWorkArea::onScrollWheel(GdkEventScroll * event)
|
|
|
|
{
|
|
|
|
Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
|
|
|
|
|
|
|
|
double step;
|
|
|
|
if (event->state & GDK_CONTROL_MASK)
|
|
|
|
step = adjustment->get_page_increment();
|
|
|
|
else
|
|
|
|
step = adjustment->get_step_increment();
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-09-24 06:32:22 +00:00
|
|
|
if (event->direction == GDK_SCROLL_UP)
|
|
|
|
step *= -1.0f;
|
|
|
|
|
2004-10-11 16:58:17 +00:00
|
|
|
double target = adjustment->get_value() + step;
|
|
|
|
// Prevent the user getting a whole screen of blank when they
|
|
|
|
// try to scroll past the end of the doc
|
|
|
|
double max = adjustment->get_upper() - workHeight();
|
|
|
|
if (target > max)
|
|
|
|
target = max;
|
2004-09-24 06:32:22 +00:00
|
|
|
|
2004-10-11 16:58:17 +00:00
|
|
|
adjustment->set_value(target);
|
2004-09-24 06:32:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-09-02 10:29:05 +00:00
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
bool GWorkArea::onButtonPress(GdkEventButton * event)
|
|
|
|
{
|
|
|
|
kb_action ka = LFUN_MOUSE_PRESS;
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
ka = LFUN_MOUSE_PRESS;
|
|
|
|
break;
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
ka = LFUN_MOUSE_DOUBLE;
|
|
|
|
break;
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
ka = LFUN_MOUSE_TRIPLE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dispatch(FuncRequest(ka,
|
|
|
|
static_cast<int>(event->x),
|
|
|
|
static_cast<int>(event->y),
|
2004-11-04 21:50:10 +00:00
|
|
|
gButtonToLyx(event->button)));
|
2003-09-02 10:29:05 +00:00
|
|
|
workArea_.grab_focus();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GWorkArea::onButtonRelease(GdkEventButton * event)
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_MOUSE_RELEASE,
|
|
|
|
static_cast<int>(event->x),
|
|
|
|
static_cast<int>(event->y),
|
2004-11-04 21:50:10 +00:00
|
|
|
gButtonToLyx(event->button)));
|
2003-09-02 10:29:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GWorkArea::onMotionNotify(GdkEventMotion * event)
|
|
|
|
{
|
|
|
|
static guint32 timeBefore;
|
|
|
|
Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
|
|
|
|
double step = adjustment->get_step_increment();
|
|
|
|
double value = adjustment->get_value();
|
|
|
|
if (event->x < 0)
|
|
|
|
value -= step;
|
|
|
|
else if (event->x > workArea_.get_height())
|
|
|
|
value += step;
|
|
|
|
if (value != adjustment->get_value()) {
|
|
|
|
if (event->time - timeBefore > 200) {
|
|
|
|
adjustment->set_value(value);
|
|
|
|
adjustment->value_changed();
|
|
|
|
}
|
|
|
|
timeBefore = event->time;
|
|
|
|
}
|
|
|
|
dispatch(FuncRequest(LFUN_MOUSE_MOTION,
|
|
|
|
static_cast<int>(event->x),
|
|
|
|
static_cast<int>(event->y),
|
|
|
|
gtkButtonState(event->state)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GWorkArea::inputCommit(gchar * str)
|
|
|
|
{
|
|
|
|
inputCache_ = Glib::locale_from_utf8(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
|
|
|
guint /*info*/)
|
|
|
|
{
|
2003-09-09 18:27:24 +00:00
|
|
|
selectionRequested();
|
2003-09-02 10:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(const_cast<GWorkArea&>(*this),
|
2003-09-02 10:29:05 +00:00
|
|
|
&GWorkArea::onClipboardGet),
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(const_cast<GWorkArea&>(*this),
|
2003-09-02 10:29:05 +00:00
|
|
|
&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));
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|