我GTK+编写了一个应用程序,用于C加载动画文件矩阵GIF。它们GtkImages在加载时自动运行动画,然后在动画完成时停止。我如何重新启动每个GtkImage包含GIF动画完成时生成的信号的动画?
谢谢。
编辑:
使用这里gdk_pixbuf_animation_get_iter()描述的可以使这成为可能吗?
下面提供了完整的代码。
/*
* Compile me with:
* gcc -o reels reels.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0)
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
/* GTK */
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
/**** prototypes ****/
static void destroy (GtkWidget*, gpointer);
GdkPixbuf *create_pixbuf(const gchar * filename);
GtkWidget *SetupWindow(gchar *data, const gchar *filename);
static void …Run Code Online (Sandbox Code Playgroud) 我有一些Gtk+编写的代码C,它使用一些动画Cairo和一个计时器.大多数情况下,当我点击关闭应用程序图标时,我在终端上收到以下消息:
Gtk-CRITICAL**:gtk_widget_queue_draw:断言`GTK_IS_WIDGET(widget)'失败
现在我假设这是在讨价还价,因为在我关闭应用程序的那一刻,计时器被触发并且主窗口小部件被访问但是后来被破坏了.确定Gtk小部件是否仍然有效且可以引用的常用方法是什么?
违规代码在这里:
gboolean rotate_cb( void *degrees )
{
rotation += DegreesToRadians((*(int*)(degrees)));
// Tell our window that it should repaint itself (ie. emit an expose event)
/* need to only call gtk_widget_queue_draw() if window is still valid / exists */
gtk_widget_queue_draw(window);
return( TRUE );
}
Run Code Online (Sandbox Code Playgroud)
我假设必须有一些方法来测试是否window仍然有效且有效?
我正在创建一个ToolStripMenu如下所示的内容,它应该允许用户与“XML”和“非 XML”项目进行交互,就好像它们是表单上的常规复选框一样。但是,当选中/取消选中一项时,菜单将关闭。如何在不关闭菜单的情况下允许选中/取消选中某个项目?或者是否有不同的标准方法来实现相同的行为?

所以我想要的是能够单击“非 XML”,显示一个复选框并使菜单保持打开状态。这个想法是,最后一个菜单项将是“完成”,当单击它时,“G2S”子项将保持打开状态,但“显示”子项(XML,非 XML)将关闭。
有任何想法吗?
注意:我知道这可能不是最好的用户界面设计。然而,我想知道如何实现这一点,只是为了获得一些有关处理菜单的技术知识。
我有一个需要解析的 XML 文件,并且正在努力使用它PugiXML来解析所有元素和属性。
我有以下 XML 文件:
<?xml version = '1.0' encoding = 'UTF-8'?>
<PanelList DefaultTheme="konami" >
<Panel xpos="0" ypos="0" width="800" height="600" imagepath="./%THEME%/background_uga_large.png" name="AttractMode0" >
<GameViewport xpos="0" ypos="0" width="630" height="526" name="gameviewport"/>
<ValueLabel xpos="120" ypos="550" width="448" height="30" fontsize="18" color="white" text="Please, insert your card" name="StatusAttract" errorimagepath="./%THEME%/panel_top_error.png" pageattpendingpath="./%THEME%/panel_top_att.png" drinkpendingpath="./%THEME%/panel_top_drink.png" onclick="ShowPanel(special_panel999)" />
<StreamingImage xpos="637" ypos="3" width="160" height="120" volume="0" text="udp:@:9001" name="attract1" />
<Image xpos="637" ypos="130" width="160" height="390" imagepath="http://n2web/images/attract-uga.gif" />
<FunctionButton xpos="6" ypos="534" width="68" height="60" imagepath="./%THEME%/button_shrink.png" clickimagepath="./%THEME%/button_shrink_down.png" name="window" onclick="ShowPanel(AttractModeSmall)"/>
<FunctionButton xpos="650" ypos="534" width="68" height="60" imagepath="./%THEME%/button_attendantstart_up.png" …Run Code Online (Sandbox Code Playgroud) 虽然我发现了一篇关于OMTvs.UML的文章但我无法弄清楚使用OMT而不是使用的后果UML- class diagram.OMT相比有UML- class diagram什么好处?到目前为止,我知道我可以用几乎相同的方式来描绘类图UML,或者是否有任何已知的情况只能OMT说明特定的上下文?还有一个更有趣的问题是,用于在两种建模工具之间进行选择的标准是什么?
这应该很简单(我认为),但我无法做到正确......:|
任务如下:
询问用户一些输入.必须将输入拆分为单个单词并放入数组中.应该计算所有单词.如果存在相等的单词,则它们在输出上得到"+1".最后,我想打印出来,并希望列表中有适当数量的计算单词.我的前两列是正确的,但是平等的话语让我头疼.如果发现一个单词是相同的,它在生成的列表中不能出现两次!!
我是一个完整的JAVA新手,所以请善待代码判断.;)
到目前为止,这是我的代码:
package MyProjects;
import javax.swing.JOptionPane;
public class MyWordCount {
public static void main(String[] args) {
//User input dialog
String inPut = JOptionPane.showInputDialog("Write som text here");
//Puts it into an array, and split it with " ".
String[] wordList = inPut.split(" ");
//Print to screen
System.out.println("Place:\tWord:\tCount: ");
//Check & init wordCount
int wordCount = 0;
for (int i = 0; i < wordList.length; i++) {
for (int j = 0; j < wordList.length; j++){
//some code here …Run Code Online (Sandbox Code Playgroud) 我有一个简单的C GTKLinux应用程序,需要将主窗口的背景设置为GIF文件中的图像.我做了一些阅读,似乎我应该能够做到以下几点:
1-将背景图像填充到
GdkPixbuf使用gdk_pixbuf_new_from_file()
2-用于gdk_pixbuf_render_pixmap_and_mask()渲染GdkPixbuf到GdkPixMap
3集的背景中GtkWindow使用gdk_window_set_back_pixmap()
呼叫gdk_window_set_back_pixmap()似乎需要一个GdKWindow而不是一个GtkWindow.我的代码不起作用,下面是我的具体问题.
Run Code Online (Sandbox Code Playgroud)/* * Compile me with: * gcc -o reels reels.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0) */ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <time.h> /* GTK */ #include <gdk/gdkx.h> #include <gtk/gtk.h> /**** prototypes ****/ static void destroy (GtkWidget*, gpointer); GdkPixbuf *create_pixbuf(const gchar * filename); /********************/ …
我正在编写一个小型演示应用程序,需要执行以下操作:
PNG图像文件PNGx 度结果应该是一系列PNG图像文件,显示不同旋转角度的图像。然后这些图像将以某种方式组合成电影或动画GIF。
我创建了以下代码来尝试进行一次旋转:
#include <cairo.h>
#include <math.h>
/**** prototypes *******/
void Rotate( cairo_surface_t *image, int degress, const char *fileName );
double DegreesToRadians( double degrees );
/***********************/
double DegreesToRadians( double degrees )
{
return((double)((double)degrees * ( (double)M_PI/(double)180.0 )));
}
void Rotate( cairo_surface_t *image, int degrees, const char *fileName )
{
int w, h;
cairo_t *cr;
cr = cairo_create(image);
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);
cairo_translate(cr, …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个返回int的方法 - 发送数组中最大整数的值.我希望这个方法工作的方法是在for循环中检查数组的第一个和最后一个元素,并以中间方式工作.所以i =第一个整数,k =最后一个整数.当i = 0, k = n-1(索引)时,i = 1, k = n-2如果你抓住我的漂移.在每个循环中都需要检查if a[i]>a[k].然后他们换位置.然后我知道最大的数字在数组的前半部分,然后我希望它检查那一半,所以最终最大的int在索引0.
我试过这样的:
public static int maxOfArray(int[] a)
{
int length = a.length;
if(length<1)
throw new NoSuchElementException("Not at least one integer in array");
while (length > 1)
{
int k = length;
for(int i = 0; i < length/2; i++)
{
k--;
if(a[i]<a[k])
{
int j = a[i];
a[i] = a[k];
a[k] = j;
}
}
length /=2; …Run Code Online (Sandbox Code Playgroud) 所以我正在尝试编写一个函数来在 MIPS 中找到字符串的长度。
我沿着数组走/遍历,加载每个字符,我想将每个字符与空终止字符进行比较,以查看字符串是否已“结束”。在每次连续迭代中,我都会增加一个计数器,然后在字符串“结束”后将计数器存储在 $v0 中。但是,如何比较当前加载的字符是否为空终止字符“\0”?更具体地说,我如何表示这个空终止字符?正如我在下面所做的那样,它是零美元吗?如果是这样,那么我还做错了什么?获取地址错误。
.data
msg1:.asciiz "Please insert text (max 20 characters): "
msg2:.asciiz "\nThe length of the text is: "
newline: .asciiz "\n"
str1: .space 20
.text
.globl main
main:
addi $v0, $v0,4
la $a0,msg1
syscall #print msg1
li $v0,8
la $a0,str1
addi $a1,$zero,20
syscall #get string 1
la $a0,str1 #pass address of str1
jal len
len:
addi $t2, $zero, 0 # $t2 is what we want to return in the end -- the count of the …Run Code Online (Sandbox Code Playgroud)