wxWidgets:集成自定义 GTK+ 小部件
wxWidgets: integrate custom GTK+ widget
问题:
如何正确实现自定义 wxSciter
控件并将其正确放置在标准 wxWidgets 控件中?
(所以它可以像浏览器一样运行 window)
已解决:
我在提供以下建议后解决了问题:
class NativeWindow : public wxNativeWindow
{
public:
explicit NativeWindow(wxWindow* parent)
: wxNativeWindow()
{
GtkWidget* widget = SAPI()->SciterCreateWindow(SW_CHILD, NULL, NULL, NULL, this->GetHandle());
g_object_ref_sink(widget);
// remove Sciter's GTK top-level container
// to prevent "Can't set a parent on widget which has a parent"
gtk_container_remove(GTK_CONTAINER(gwindow(widget)), widget);
SAPI()->SciterLoadFile(widget, WSTR("http://linux.org.ru/"));
(void)Create(parent, wxID_ANY, widget);
}
virtual ~NativeWindow()
{
Disown();
}
};
wxNativeWindow normally should allow you to do what you need with very little effort. You can find a fuller example of using it than the one given in the docs in the widgets sample, see its GTK-specific part.
问题:
如何正确实现自定义 wxSciter
控件并将其正确放置在标准 wxWidgets 控件中?
(所以它可以像浏览器一样运行 window)
已解决:
我在提供以下建议后解决了问题:
class NativeWindow : public wxNativeWindow
{
public:
explicit NativeWindow(wxWindow* parent)
: wxNativeWindow()
{
GtkWidget* widget = SAPI()->SciterCreateWindow(SW_CHILD, NULL, NULL, NULL, this->GetHandle());
g_object_ref_sink(widget);
// remove Sciter's GTK top-level container
// to prevent "Can't set a parent on widget which has a parent"
gtk_container_remove(GTK_CONTAINER(gwindow(widget)), widget);
SAPI()->SciterLoadFile(widget, WSTR("http://linux.org.ru/"));
(void)Create(parent, wxID_ANY, widget);
}
virtual ~NativeWindow()
{
Disown();
}
};
wxNativeWindow normally should allow you to do what you need with very little effort. You can find a fuller example of using it than the one given in the docs in the widgets sample, see its GTK-specific part.