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"
20 #include <X11/Xft/Xft.h>
24 typedef std::map<LColor::color, Gdk::Color *> Map;
25 typedef Map::iterator MapIt;
26 typedef std::map<LColor::color, XftColor *> Map2;
27 typedef Map2::iterator MapIt2;
29 ~ColorCache() { clear(); }
30 Gdk::Color * getColor(LColor::color clr)
32 MapIt it = cache_.find(clr);
33 return it == cache_.end() ? 0 : it->second;
35 XftColor * getXftColor(LColor::color clr)
37 MapIt2 it = cache2_.find(clr);
38 return it == cache2_.end() ? 0 : it->second;
40 void cacheColor(LColor::color clr, Gdk::Color * gclr)
44 void cacheXftColor(LColor::color clr, XftColor * xclr)
54 extern ColorCache colorCache;
59 ColorHandler(GWorkArea& owner) : owner_(owner) {}
60 XftColor * getXftColor(LColor::color clr);
61 Gdk::Color * getGdkColor(LColor::color clr);
66 class GWorkArea : public WorkArea, public SigC::Object
69 GWorkArea(int width, int height);
72 virtual Painter & getPainter() { return painter_; }
74 virtual int workWidth() const { return workArea_.get_width(); }
76 virtual int workHeight() const { return workArea_.get_height(); }
77 /// return x position of window
78 int xpos() const { return 0; }
79 /// return y position of window
80 int ypos() const { return 0; }
82 Glib::RefPtr<Gdk::Window> getWindow() { return workArea_.get_window(); }
83 Display * getDisplay() const
84 { return GDK_WINDOW_XDISPLAY(
85 const_cast<GdkWindow*>(workArea_.get_window()->gobj())); }
86 Glib::RefPtr<Gdk::Pixmap> getPixmap() { return workAreaPixmap_; }
87 Glib::RefPtr<Gdk::GC> getGC() { return workAreaGC_; }
88 Glib::RefPtr<Gdk::Colormap> getColormap()
89 { return workArea_.get_colormap(); }
90 XftDraw * getXftDraw() { return draw_; }
91 ColorHandler & getColorHandler() { return colorHandler_; }
93 virtual void setScrollbarParams(int height, int pos, int line_height);
94 /// a selection exists
95 virtual void haveSelection(bool) const;
97 virtual string const getClipboard() const;
99 virtual void putClipboard(string const &) const;
100 void inputCommit(gchar * str);
102 bool onExpose(GdkEventExpose * event);
103 bool onConfigure(GdkEventConfigure * event);
105 bool onButtonPress(GdkEventButton * event);
106 bool onButtonRelease(GdkEventButton * event);
107 bool onMotionNotify(GdkEventMotion * event);
108 bool onKeyPress(GdkEventKey * event);
109 void onClipboardGet(Gtk::SelectionData& selection_data, guint info);
110 void onClipboardClear();
112 Gtk::DrawingArea workArea_;
113 Gtk::VScrollbar vscrollbar_;
114 /// The pixmap overlay on the workarea
115 Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
116 Glib::RefPtr<Gdk::GC> workAreaGC_;
117 /// the xforms-specific painter
120 ColorHandler colorHandler_;
121 GtkIMContext * imContext_;