diff --git a/uppsrc/CtrlLib/RichTextView.cpp b/uppsrc/CtrlLib/RichTextView.cpp index faa30b5ed..ad0f931a1 100644 --- a/uppsrc/CtrlLib/RichTextView.cpp +++ b/uppsrc/CtrlLib/RichTextView.cpp @@ -85,7 +85,7 @@ Image RichTextView::CursorImage(Point p, dword keyflags) { int pos = GetPointPos(p); if(WhenLink && pos >= 0 && !IsNull(GetLink(pos, p))) - return CtrlImg::HandCursor(); + return Image::Hand(); if(HasCapture()) return Image::IBeam(); return Image::Arrow(); diff --git a/uppsrc/GLCtrl/GLCtrl.cpp b/uppsrc/GLCtrl/GLCtrl.cpp index 84f29c14d..b970ed2fe 100644 --- a/uppsrc/GLCtrl/GLCtrl.cpp +++ b/uppsrc/GLCtrl/GLCtrl.cpp @@ -20,6 +20,8 @@ void GLCtrl::StdView() glLoadIdentity(); } +#ifndef GUI_GTK + Image GLCtrl::GLPane::MouseEvent(int event, Point p, int zdelta, dword keyflags) { p = p - GetScreenView().TopLeft() + ctrl->GetScreenView().TopLeft(); @@ -32,4 +34,6 @@ Vector GLCtrl::Pick(int x, int y) return picking.Pick(x, y, THISBACK2(GLResize, GetSize().cx, GetSize().cy), THISBACK(GLPickingPaint)); } +#endif + END_UPP_NAMESPACE diff --git a/uppsrc/GLCtrl/GLCtrl.h b/uppsrc/GLCtrl/GLCtrl.h index 5f58230c0..189ce3886 100644 --- a/uppsrc/GLCtrl/GLCtrl.h +++ b/uppsrc/GLCtrl/GLCtrl.h @@ -27,6 +27,22 @@ NAMESPACE_UPP +#ifdef GUI_GTK + +class GLCtrl : public Ctrl { +public: + virtual void Paint(Draw& w); + +public: + Callback WhenGLPaint; + + virtual void GLPaint(); + + void StdView(); +}; + +#else + class GLCtrl : public Ctrl { typedef GLCtrl CLASSNAME; @@ -155,6 +171,8 @@ public: Vector Pick(int x, int y); }; +#endif + END_UPP_NAMESPACE #endif diff --git a/uppsrc/GLCtrl/GLCtrl.upp b/uppsrc/GLCtrl/GLCtrl.upp index 4b22b672e..0f5a7420c 100644 --- a/uppsrc/GLCtrl/GLCtrl.upp +++ b/uppsrc/GLCtrl/GLCtrl.upp @@ -7,10 +7,13 @@ library(LINUX) "GL GLU"; library(FREEBSD) "GL GLU"; +library(GTK) "gdkglext-x11-1.0 gtkglext-x11-1.0"; + file GLCtrl.h, GLPicking.cpp, Win32GLCtrl.cpp, X11GLCtrl.cpp, + GtkGLCtrl.cpp, GLCtrl.cpp; diff --git a/uppsrc/GLCtrl/GLPicking.cpp b/uppsrc/GLCtrl/GLPicking.cpp index ddf416518..8082894ba 100644 --- a/uppsrc/GLCtrl/GLPicking.cpp +++ b/uppsrc/GLCtrl/GLPicking.cpp @@ -2,6 +2,8 @@ NAMESPACE_UPP +#if defined(GUI_X11) || defined(GUI_WIN32) + void GLCtrl::GLPicking::InitPickMatrix() { if (_isPicking) @@ -58,4 +60,6 @@ Vector GLCtrl::GLPicking::ParseHits(GLuint *buffer, int hits) return result; } +#endif + END_UPP_NAMESPACE diff --git a/uppsrc/GLCtrl/GtkGLCtrl.cpp b/uppsrc/GLCtrl/GtkGLCtrl.cpp new file mode 100644 index 000000000..12bf6a58d --- /dev/null +++ b/uppsrc/GLCtrl/GtkGLCtrl.cpp @@ -0,0 +1,69 @@ +#include "GLCtrl.h" + +#ifdef GUI_GTK + +#include +#include +#include + +NAMESPACE_UPP + +GdkGLConfig *sGlconfig; + +EXITBLOCK { + if(sGlconfig) + g_object_unref(G_OBJECT(sGlconfig)); +} + +void GLCtrl::GLPaint() +{ + WhenGLPaint(); +} + +void GLCtrl::Paint(Draw& w) +{ + Size sz = GetSize(); + + Ctrl *top = GetTopCtrl(); + if(!top) + return; + + GtkWindow *gtk = top->gtk(); + GdkWindow *win = top->gdk(); + + if(sz.cx <= 0 || sz.cy <= 0 || !win || !gtk) + return; + + ONCELOCK { + sGlconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode)(GDK_GL_MODE_RGB|GDK_GL_MODE_DEPTH|GDK_GL_MODE_SINGLE)); + } + + GdkPixmap *pixmap = gdk_pixmap_new(win, sz.cx, sz.cy, -1); + if(pixmap) { + GdkGLDrawable *gldrawable = GDK_GL_DRAWABLE(gdk_pixmap_set_gl_capability(pixmap, sGlconfig, NULL)); + if(gldrawable) { + GdkGLContext *glcontext = gdk_gl_context_new(gldrawable, NULL, FALSE, GDK_GL_RGBA_TYPE); + if(glcontext) { + if(gdk_gl_drawable_gl_begin(gldrawable, glcontext)) { + glViewport(0, 0, sz.cx, sz.cy); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GLPaint(); + glFlush (); + gdk_gl_drawable_gl_end(gldrawable); + + Rect r = GetScreenView() - GetTopCtrl()->GetScreenView().TopLeft(); + GtkWidget *widget = GTK_WIDGET(gtk); + gdk_draw_drawable(win, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + pixmap, 0, 0, r.left, r.top, r.GetWidth(), r.GetHeight()); + } + g_object_unref(G_OBJECT(glcontext)); + } + g_object_unref(G_OBJECT(gldrawable)); + } + g_object_unref(G_OBJECT(pixmap)); + } +} + +END_UPP_NAMESPACE + +#endif