]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GWorkArea.h
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GWorkArea.h
1 // -*- C++ -*-
2 /**
3  * \file GWorkArea.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Huang Ying
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GWORKAREA_H
13 #define GWORKAREA_H
14
15 #include "GPainter.h"
16
17 #include "frontends/WorkArea.h"
18
19 #include <gtkmm.h>
20 #include <gtk/gtk.h>
21
22 #include <X11/Xft/Xft.h>
23
24 class LColor_color;
25 class LyXView;
26
27 namespace lyx {
28 namespace frontend {
29
30 class ColorCache {
31 public:
32         typedef std::map<LColor_color, boost::shared_ptr<Gdk::Color> > Map;
33         typedef Map::iterator MapIt;
34         typedef std::map<LColor_color, boost::shared_ptr<XftColor> > Map2;
35         typedef Map2::iterator MapIt2;
36         Gdk::Color * getColor(LColor_color);
37         XftColor * getXftColor(LColor_color);
38         void cacheColor(LColor_color, Gdk::Color *);
39         void cacheXftColor(LColor_color, XftColor *);
40         void clear();
41 private:
42         Map cache_;
43         Map2 cache2_;
44 };
45
46 extern ColorCache colorCache;
47
48 class ColorHandler {
49 public:
50         ColorHandler(GWorkArea & owner) : owner_(owner) {}
51         XftColor * getXftColor(LColor_color clr);
52         Gdk::Color * getGdkColor(LColor_color clr);
53 private:
54         GWorkArea & owner_;
55 };
56
57
58 class GWorkArea : public WorkArea, public sigc::trackable {
59 public:
60         GWorkArea(LyXView & owner, int width, int height);
61         ~GWorkArea();
62
63         virtual Painter & getPainter();
64         ///
65         virtual int workWidth() const;
66         ///
67         virtual int workHeight() const;
68         /// return x position of window
69         int xpos() const;
70         /// return y position of window
71         int ypos() const;
72         ///
73         Glib::RefPtr<Gdk::Window> getWindow();
74         Display * getDisplay() const;
75         Glib::RefPtr<Gdk::Pixmap> getPixmap();
76         Glib::RefPtr<Gdk::GC> getGC();
77         Glib::RefPtr<Gdk::Colormap> getColormap();
78         XftDraw * getXftDraw();
79         ColorHandler & getColorHandler();
80
81         virtual void setScrollbarParams(int height, int pos, int line_height);
82         /// a selection exists
83         virtual void haveSelection(bool) const;
84         ///
85         virtual std::string const getClipboard() const;
86         ///
87         virtual void putClipboard(std::string const &) const;
88         void inputCommit(gchar * str);
89 private:
90         bool onExpose(GdkEventExpose * event);
91         bool onConfigure(GdkEventConfigure * event);
92         void onScroll();
93         bool onScrollWheel(GdkEventScroll * event);
94         bool onButtonPress(GdkEventButton * event);
95         bool onButtonRelease(GdkEventButton * event);
96         bool onMotionNotify(GdkEventMotion * event);
97         bool onKeyPress(GdkEventKey * event);
98         void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
99         void onClipboardClear();
100         Gtk::HBox hbox_;
101         Gtk::DrawingArea workArea_;
102         Gtk::VScrollbar vscrollbar_;
103         /// The pixmap overlay on the workarea
104         Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
105         Glib::RefPtr<Gdk::GC> workAreaGC_;
106         /// the xforms-specific painter
107         GPainter painter_;
108         XftDraw * draw_;
109         ColorHandler colorHandler_;
110         GtkIMContext * imContext_;
111         std::string inputCache_;
112 };
113
114 } // namespace frontend
115 } // namespace lyx
116
117 #endif