调用 gdk_get_pixmap 需要什么?

发布于 2024-09-16 03:10:20 字数 979 浏览 4 评论 0原文

我创建了一个小的绘图区域类,现在需要一个像素图来在公开事件回调期间绘制。但我无法获取我尝试编译的任何参数。以下是代码的相关部分...

类定义...

class set_display_drawing_area : public Gtk::DrawingArea
{
    public:
        set_display_drawing_area          ();
        virtual ~set_display_drawing_area ();
    protected:
        virtual bool on_expose_event(GdkEventExpose* event);
    private:
        GdkPixmap              *pixmap_ptr;
};

以及公开回调...

bool set_display_drawing_area::on_expose_event(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Window> window = get_window();

    if (window)
    {
        Gtk::Allocation allocation = get_allocation();
        const int width = allocation.get_width();
        const int height = allocation.get_height();

        pixmap_ptr = gdk_pixmap_new (window,    // <-- What is needed here?
                                     width,
                                     height,
                                     -1);

I have created a little drawing area class and now need a pixmap to draw into during the expose event callback. But I can't get any parameter that I have tried to compile. Here are the relevant parts of the code...

The class definition...

class set_display_drawing_area : public Gtk::DrawingArea
{
    public:
        set_display_drawing_area          ();
        virtual ~set_display_drawing_area ();
    protected:
        virtual bool on_expose_event(GdkEventExpose* event);
    private:
        GdkPixmap              *pixmap_ptr;
};

and the expose callback...

bool set_display_drawing_area::on_expose_event(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Window> window = get_window();

    if (window)
    {
        Gtk::Allocation allocation = get_allocation();
        const int width = allocation.get_width();
        const int height = allocation.get_height();

        pixmap_ptr = gdk_pixmap_new (window,    // <-- What is needed here?
                                     width,
                                     height,
                                     -1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぃ双果 2024-09-23 03:10:20

您在这里混合了 gtkmm (C++) 和 gtk (C) 风格的代码。 gdk_pixmap_new 是一个 C 函数,它不了解模板和类(例如 Glib::RefPtr)。您可能还想对您的像素图使用 gtkmm:

Glib::RefPtr<Gdk::Pixmap> pixmap;

pixmap = Gdk::Pixmap::create(window, width, height);

You're mixing gtkmm (C++) and gtk (C) style code here. gdk_pixmap_new is a C function which has no idea about templates and classes (such as Glib::RefPtr). You'll probably want to use gtkmm for your pixmap as well:

Glib::RefPtr<Gdk::Pixmap> pixmap;

and

pixmap = Gdk::Pixmap::create(window, width, height);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文