登录 用户中心() [退出] 后台管理 注册
 

热门搜索:
您的位置:首页 >> 程序员下载区 >> 程序员下载区 >> 主题: 画 gtk 程序图标(xpm格式)的好工具 gimp (windows版)
标题 画 gtk 程序图标(xpm格式)的好工具 gimp (windows版)
clq
浏览(2023) 2006-12-05 16:45:39 发表 编辑

关键字:

画 gtk 程序图标(xpm格式)的好工具 gimp (windows版)


最近在做gtk,它的图标格式非常有意思,直接就是 C 语言的字符串缓冲代码(!),类似于这样:

/* XPM */
static char * gtk_xpm[] = {
"32 39 5 1",
". c none",
"+ c black",
"@ c #3070E0",
"# c #F05050",
"$ c #35E035",
"................+...............",
"..............+++++.............",
"............+++++@@++...........",
"..........+++++@@@@@@++.........",
"........++++@@@@@@@@@@++........",
"......++++@@++++++++@@@++.......",
".....+++@@@+++++++++++@@@++.....",
"...+++@@@@+++@@@@@@++++@@@@+....",
"..+++@@@@+++@@@@@@@@+++@@@@@++..",
".++@@@@@@+++@@@@@@@@@@@@@@@@@@++",
".+#+@@@@@@++@@@@+++@@@@@@@@@@@@+",
".+##++@@@@+++@@@+++++@@@@@@@@$@.",
".+###++@@@@+++@@@+++@@@@@++$$$@.",
".+####+++@@@+++++++@@@@@+@$$$$@.",
".+#####+++@@@@+++@@@@++@$$$$$$+.",
".+######++++@@@@@@@++@$$$$$$$$+.",
".+#######+##+@@@@+++$$$$$$@@$$+.",
".+###+++##+##+@@++@$$$$$$++$$$+.",
".+###++++##+##+@@$$$$$$$@+@$$@+.",
".+###++++++#+++@$$@+@$$@++$$$@+.",
".+####+++++++#++$$@+@$$++$$$$+..",
".++####++++++#++$$@+@$++@$$$$+..",
".+#####+++++##++$$++@+++$$$$$+..",
".++####+++##+#++$$+++++@$$$$$+..",
".++####+++####++$$++++++@$$$@+..",
".+#####++#####++$$+++@++++@$@+..",
".+#####++#####++$$++@$$@+++$@@..",
".++####++#####++$$++$$$$$+@$@++.",
".++####++#####++$$++$$$$$$$$+++.",
".+++####+#####++$$++$$$$$$$@+++.",
"..+++#########+@$$+@$$$$$$+++...",
"...+++########+@$$$$$$$$@+++....",
".....+++######+@$$$$$$$+++......",
"......+++#####+@$$$$$@++........",
".......+++####+@$$$$+++.........",
".........++###+$$$@++...........",
"..........++##+$@+++............",
"...........+++++++..............",
".............++++..............."};

我在想用什么样的程序来生成它好呢?当然应该找linux下的,刚好gtk就是为gimp而写的.找了一个windows版本,哈哈,果然不错.

--------------------------------------------------
另外说一下在gtk程序中的调用方法,例子如下:


#include "create_toolbar.h"

/* XPM */
static char * t1_xpm[] = {
"32 32 91 1",
". c None",
" c #000000",
"+ c #C4C4C4",
"@ c #55FD55",
"# c #98FE98",
..太多,省略..
"................................",
"................................",
"................................"};

void create_toolbar()
{
GtkWidget * toolbar;
GtkWidget* close_button;
GtkWidget* start_button;

//图标
GdkPixbuf * pbuf = gdk_pixbuf_new_from_xpm_data( (const char **)t1_xpm );
//GtkWidget * iconw = gtk_image_new_from_file ("gtk.xpm"); /* 图标构件 */
GtkWidget * iconw = gtk_image_new_from_pixbuf ( (GdkPixbuf *) pbuf); /* 图标构件 */

toolbar = gtk_toolbar_new ();
gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 5);

close_button =
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), /* 工具栏 */
"Close", /* 按钮标签 */
"Closes this app", /* 按钮的工具提示 */
"Private", /* 工具提示的私有信息 */
NULL, /* 图标构件 */
NULL, /* 一个信号 */
NULL);

start_button =
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), /* 工具栏 */
"Start", /* 按钮标签 */
"Start...", /* 按钮的工具提示 */
"Private", /* 工具提示的私有信息 */
iconw,//NULL, /* 图标构件 */
GTK_SIGNAL_FUNC (start_event), /* 一个信号 */
NULL);

/* 要将一个构件组装到工具栏上,只需创建它,然后将它追
* 加到工具栏上,同时设置合适的工具提示 */
GtkWidget* entry = gtk_entry_new ();
gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar),
entry,
"This is just an entry",
"Private");

/* 因为它不是工具栏自己创建的,所以我们还需要显示它 */
gtk_widget_show (entry);

... gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); /* 工具栏项后的空白 */


/* 最后一步是显示新创建的按钮和窗口 */
gtk_widget_show (close_button);
gtk_widget_show (toolbar);

gtk_table_attach (GTK_TABLE (table),
toolbar,
0, 1,
1, 2,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0,
0, 0);

}

代码参考了 http://reciteword.cosoft.org.cn/yaoguang/ebook/gtk2-tut/x1465.html 的一部分.
--------------------------------------------------
注意要加入 gdk-win32-2.0.lib gdk_pixbuf-2.0.lib 的连接库.

--------------------------------------------------
下载地址:

点击这里下载


总数:0 页次:1/0 首页 尾页  


发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:




Copyright © 2005-2012 CLQ工作室, All Rights Reserved

CLQ工作室 版权所有