[英]How to create a window like Google Chrome in GTK+
I'm pretty new to GTK libraries and trying to develop a small project in GTK+2 with its C API's. 我是GTK库的新手,并尝试使用其C API开发GTK + 2中的小项目。 The requirement is to do it in a Google-Chrome type window .
要求是在Google-Chrome类型窗口中执行此操作 。 It'll be having it's own title bar and controls with different colors.
它将拥有自己的标题栏和不同颜色的控件。
Can anybody help me out with any tutorial or reference or any opensource code that already implemented this? 任何人都可以帮我解决任何教程或参考或任何已实现此功能的开源代码吗?
I appreciate your help. 我感谢您的帮助。
Since the Crhomium browser is an open source project, its source is available here: http://src.chromium.org/viewvc/chrome/trunk/ 由于Crhomium浏览器是一个开源项目,其源代码可在此处获取: http ://src.chromium.org/viewvc/chrome/trunk/
What you seek should by definition be available there :) 根据定义你应该找到什么:)
What you want to do is custom decoration. 你想要做的是定制装饰。
My understanding is that you have to set_decorated False on the window so that the WM doesn't add border/title bar itself to your windows and then have your own custom Window subclass that handles drawing it's decorations itself manually in the paint()
method. 我的理解是你必须在窗口上set_decorated False,以便WM不会将边框/标题栏本身添加到你的窗口,然后拥有自己的自定义Window子类,它可以在
paint()
方法中手动处理它的装饰本身。
Not trivial. 不是微不足道的。
what you might be looking for is the gtk wheelbarrow example. 您可能正在寻找的是gtk独轮车示例。 It shows you how to create a shaped window using an xpm file.there is an example in C, Perl and Python.
它向您展示了如何使用xpm文件创建一个整形窗口。这是C,Perl和Python中的一个示例。 I did one of these a few years back but haven't used it for some time now.
几年前我做了其中一个,但现在已经有一段时间没用过了。
Here is the C version ... 这是C版 ......
The Python Example is Here ... Python示例就在这里 ......
Here is a tutorial on pixmaps and GTK+ 这是关于pixmaps和GTK +的教程
Just create your image with Gimp and save it as an xpm file. 只需使用Gimp创建您的图像并将其另存为xpm文件。
Adding to 246tNt's answer, Chrome uses Skia. 添加到246tNt的答案,Chrome使用Skia。 Here is an example (Gtk+ 3, cairo, skia):
这是一个例子(Gtk + 3,cairo,skia):
g_signal_connect(window_container_, "draw",
G_CALLBACK(OnWindowContainerDraw), NULL);
gboolean OnWindowContainerDraw(GtkWidget* widget,
cairo_t *cr) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
bitmap.allocPixels();
SkDevice device(bitmap);
SkCanvas canvas(&device);
SkPaint paint;
SkRect r;
paint.setARGB(255, 255, 255, 255);
r.set(10, 10, 20, 20);
canvas.drawRect(r, paint);
cairo_surface_t* surface = cairo_image_surface_create_for_data(
(unsigned char*)bitmap.getPixels(), CAIRO_FORMAT_ARGB32,
bitmap.width(), bitmap.height(), bitmap.rowBytes());
cairo_surface_mark_dirty(surface);
cairo_set_source_surface(cr, surface, 0, 0);
cairo_paint(cr);
return FALSE;
}
I'm a bit confused as to what you're actually looking for, but I think that what you want is a control that provides a web browser inside your window. 我对你真正想要的东西感到有点困惑,但我认为你想要的是一个在你的窗口内提供Web浏览器的控件。
WebKitGTK+ is one such control: http://webkitgtk.org/ WebKitGTK +就是这样一个控件: http ://webkitgtk.org/
GtkMozEmbed is another: http://www.mozilla.org/unix/gtk-embedding.html GtkMozEmbed是另一个: http : //www.mozilla.org/unix/gtk-embedding.html
Last time I did this, I had to try a few to find one that worked. 上次我这样做,我不得不尝试一些找到一个有效的。 The controls have different bugs and support for HTML (and Flash.)
控件有不同的错误和HTML(和Flash)支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.