]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GWorkArea.h
Minipage is no more (long live the box inset)
[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 #include <gdk/gdkx.h>
17 #include <gtk/gtk.h>
18
19 #include "frontends/WorkArea.h"
20
21 #include <X11/Xft/Xft.h>
22
23 class LColor_color;
24
25 class ColorCache
26 {
27         typedef std::map<LColor_color, Gdk::Color *> Map;
28         typedef Map::iterator MapIt;
29         typedef std::map<LColor_color, XftColor *> Map2;
30         typedef Map2::iterator MapIt2;
31 public:
32         ~ColorCache();
33         Gdk::Color * getColor(LColor_color);
34         XftColor * getXftColor(LColor_color);
35         void cacheColor(LColor_color, Gdk::Color *);
36         void cacheXftColor(LColor_color, XftColor *);
37         void clear();
38 private:
39         Map cache_;
40         Map2 cache2_;
41 };
42
43 extern ColorCache colorCache;
44
45 class ColorHandler
46 {
47 public:
48         ColorHandler(GWorkArea& owner) : owner_(owner) {}
49         XftColor * getXftColor(LColor_color clr);
50         Gdk::Color * getGdkColor(LColor_color clr);
51 private:
52         GWorkArea & owner_;
53 };
54
55
56 class GWorkArea : public WorkArea, public SigC::Object
57 {
58 public:
59         GWorkArea(int width, int height);
60         ~GWorkArea();
61
62         virtual Painter & getPainter();
63         ///
64         virtual int workWidth() const;
65         ///
66         virtual int workHeight() const;
67         /// return x position of window
68         int xpos() const;
69         /// return y position of window
70         int ypos() const;
71         ///
72         Glib::RefPtr<Gdk::Window> getWindow();
73         Display * getDisplay() const;
74         Glib::RefPtr<Gdk::Pixmap> getPixmap();
75         Glib::RefPtr<Gdk::GC> getGC();
76         Glib::RefPtr<Gdk::Colormap> getColormap();
77         XftDraw * getXftDraw();
78         ColorHandler & getColorHandler();
79
80         virtual void setScrollbarParams(int height, int pos, int line_height);
81         /// a selection exists
82         virtual void haveSelection(bool) const;
83         ///
84         virtual std::string const getClipboard() const;
85         ///
86         virtual void putClipboard(std::string const &) const;
87         void inputCommit(gchar * str);
88 private:
89         bool onExpose(GdkEventExpose * event);
90         bool onConfigure(GdkEventConfigure * event);
91         void onScroll();
92         bool onButtonPress(GdkEventButton * event);
93         bool onButtonRelease(GdkEventButton * event);
94         bool onMotionNotify(GdkEventMotion * event);
95         bool onKeyPress(GdkEventKey * event);
96         void onClipboardGet(Gtk::SelectionData& selection_data, guint info);
97         void onClipboardClear();
98         Gtk::HBox hbox_;
99         Gtk::DrawingArea workArea_;
100         Gtk::VScrollbar vscrollbar_;
101         /// The pixmap overlay on the workarea
102         Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
103         Glib::RefPtr<Gdk::GC> workAreaGC_;
104         /// the xforms-specific painter
105         GPainter painter_;
106         XftDraw * draw_;
107         ColorHandler colorHandler_;
108         GtkIMContext * imContext_;
109         std::string inputCache_;
110 };
111
112 #endif