在 Gtk 中如何检查窗口是否最大化?
我想仅在最大化时为窗口赋予特定属性,并在最大化状态结束时将其更改回来。我正在使用 Gtk# ,但欢迎所有 GTK 绑定答案。我正在寻找的是这样的(伪代码):
OnMaximise += new Mhandler();
Mhandler(){ property = true;}
或:
Resize += delegate() {
if (isMaximised()) property=true; else property = false;};
或 C 方式:
gtk_window_on_maximise(GTK_WINDOW(mwin),onmax);
void onmax()
{
if (gtk_window_is_max(GTK_WINDOW(mwin))
gtk_window_set_property(GTK_WINDOW(mwin),true);
else gtk_window_set_property(GTK_WINDOW(mwin),false);
}
有什么建议吗?谢谢
I want to give a window a specific property only when it is maximised and change it back when the maximised state ends. I am using Gtk# , but all GTK binding answers are welcome. What I am looking for is something like this (pseudocode):
OnMaximise += new Mhandler();
Mhandler(){ property = true;}
or:
Resize += delegate() {
if (isMaximised()) property=true; else property = false;};
or the C way:
gtk_window_on_maximise(GTK_WINDOW(mwin),onmax);
void onmax()
{
if (gtk_window_is_max(GTK_WINDOW(mwin))
gtk_window_set_property(GTK_WINDOW(mwin),true);
else gtk_window_set_property(GTK_WINDOW(mwin),false);
}
Any suggestions? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建窗口时设置“窗口状态事件”信号并监视它。请参阅 http://developer.gnome.org/gtk/2.24/ GtkWindow.html#gtk-window-maximize
还有
http://developer.gnome.org/gtk/2.24 /GtkWidget.html#GtkWidget-window-state-event
您的 onmax() 将是在以下情况下调用的处理程序GDK_WINDOW_STATE_MAXIMIZED 变为 TRUE。
请参阅 http://developer.gnome.org/ gdk/stable/gdk-Events.html#GDK-STRUCTURE-MASK:CAPS
和 http://developer.gnome.org/gdk/stable/ gdk-Event-Structures.html#GdkEventWindowState
和 http://developer.gnome.org/gdk/stable/ gdk-Event-Structures.html#GdkWindowState
抱歉,如果不实际编写代码,无法提供更多帮助。谷歌可能有一些很好的例子,但也可能没有。这些文档实际上是为那些已经可以处理 GTK+ 信号的人提供的。
编辑:我用 C 语言做 GTK+,我引用的页面是针对 C 的。
编辑 #2:只要发送信号,处理程序(回调)就会执行,并且信号数据才是重要的。我可能会对我感兴趣的每个信号数据值执行 switch:case 操作,并可能为其他函数设置一个标志以供稍后读取。
Set up the "window-state-event" signal when you create the window and watch for it. See http://developer.gnome.org/gtk/2.24/GtkWindow.html#gtk-window-maximize
and also
http://developer.gnome.org/gtk/2.24/GtkWidget.html#GtkWidget-window-state-event
Your onmax() would be the handler that would be called when GDK_WINDOW_STATE_MAXIMIZED becomes TRUE.
See http://developer.gnome.org/gdk/stable/gdk-Events.html#GDK-STRUCTURE-MASK:CAPS
and http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventWindowState
and http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkWindowState
Sorry, can't help much more than that without actually writing code. Google might have some good examples and then again might not. What documentation there is actually is for people who can already do GTK+ signals.
EDIT: I do GTK+ in C and the pages I cited are for C.
EDIT #2: The handler (callback) is executed whenever the signal is sent and the signal data is what matters. I would probably do a switch:case on each signal data value that interested me and possibly set a flag for other functions to read later on.