4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "frontends/WorkArea.h"
19 #include <X11/Xft/Xft.h>
25 typedef std::map<EnumLColor, Gdk::Color *> Map;
26 typedef Map::iterator MapIt;
27 typedef std::map<EnumLColor, XftColor *> Map2;
28 typedef Map2::iterator MapIt2;
30 ~ColorCache() { clear(); }
31 Gdk::Color * getColor(EnumLColor clr)
33 MapIt it = cache_.find(clr);
34 return it == cache_.end() ? 0 : it->second;
36 XftColor * getXftColor(EnumLColor clr)
38 MapIt2 it = cache2_.find(clr);
39 return it == cache2_.end() ? 0 : it->second;
41 void cacheColor(EnumLColor clr, Gdk::Color * gclr)
45 void cacheXftColor(EnumLColor clr, XftColor * xclr)
55 extern ColorCache colorCache;
60 ColorHandler(GWorkArea& owner) : owner_(owner) {}
61 XftColor * getXftColor(EnumLColor clr);
62 Gdk::Color * getGdkColor(EnumLColor clr);
67 class GWorkArea : public WorkArea, public SigC::Object
70 GWorkArea(int width, int height);
73 virtual Painter & getPainter() { return painter_; }
75 virtual int workWidth() const { return workArea_.get_width(); }
77 virtual int workHeight() const { return workArea_.get_height(); }
78 /// return x position of window
79 int xpos() const { return 0; }
80 /// return y position of window
81 int ypos() const { return 0; }
83 Glib::RefPtr<Gdk::Window> getWindow() { return workArea_.get_window(); }
84 Display * getDisplay() const
85 { return GDK_WINDOW_XDISPLAY(
86 const_cast<GdkWindow*>(workArea_.get_window()->gobj())); }
87 Glib::RefPtr<Gdk::Pixmap> getPixmap() { return workAreaPixmap_; }
88 Glib::RefPtr<Gdk::GC> getGC() { return workAreaGC_; }
89 Glib::RefPtr<Gdk::Colormap> getColormap()
90 { return workArea_.get_colormap(); }
91 XftDraw * getXftDraw() { return draw_; }
92 ColorHandler & getColorHandler() { return colorHandler_; }
94 virtual void setScrollbarParams(int height, int pos, int line_height);
95 /// a selection exists
96 virtual void haveSelection(bool) const;
98 virtual string const getClipboard() const;
100 virtual void putClipboard(string const &) const;
101 void inputCommit(gchar * str);
103 bool onExpose(GdkEventExpose * event);
104 bool onConfigure(GdkEventConfigure * event);
106 bool onButtonPress(GdkEventButton * event);
107 bool onButtonRelease(GdkEventButton * event);
108 bool onMotionNotify(GdkEventMotion * event);
109 bool onKeyPress(GdkEventKey * event);
110 void onClipboardGet(Gtk::SelectionData& selection_data, guint info);
111 void onClipboardClear();
113 Gtk::DrawingArea workArea_;
114 Gtk::VScrollbar vscrollbar_;
115 /// The pixmap overlay on the workarea
116 Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
117 Glib::RefPtr<Gdk::GC> workAreaGC_;
118 /// the xforms-specific painter
121 ColorHandler colorHandler_;
122 GtkIMContext * imContext_;