| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 749 人关注过本帖
标题:调节界面求
只看楼主 加入收藏
HAN2008
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2008-9-21
收藏
 问题点数:0 回复次数:4 
调节界面求
#include <gtk_api.h>
#include <core.h>
/* [url=http://library.]http://library.[/url] */
/* [url=http://library.]http://library.[/url] */
static void toolwin_create(GtkWidget *vbox);
static void textwin_create(GtkWidget *vbox);
static void topwin_create(GtkWidget *vbox);
static void midwin_create(GtkWidget *vbox);
static void bottomwin_create(GtkWidget *vbox);
static void add_widget_to_window(GtkWidget *window, GtkWidget *widget);
/* core */
static GtkWidget *build_window(void);
static GtkWidget *build_main_vbox(void);
/* others api */
static void unfocus_combo_arrow(GtkWidget *widget, gpointer data);
static void unfocus_combo_arrow(GtkWidget *widget, gpointer data)
{
 if (!GTK_IS_ENTRY(widget))
  GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
}
GtkWidget *ListWin_Create(void)
{
 GtkCellRenderer *renderer;
 GtkTreeViewColumn *column;
 GtkTreeSelection *selection;
 GtkWidget *scrolledwindow;
 GtkListStore *list_model;
 GtkTreeView *treeview_;
 list_model = gtk_list_store_new (1, G_TYPE_STRING);
 treeview_ = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_model)));
 gtk_widget_show(GTK_WIDGET(treeview_));
 gtk_tree_view_set_rules_hint(treeview_, TRUE);
 gtk_tree_view_set_headers_visible(treeview_, FALSE);
 renderer = gtk_cell_renderer_text_new ();
 column = gtk_tree_view_column_new_with_attributes ("word", renderer,
           "text", 0, NULL);
 gtk_tree_view_append_column(treeview_, column);
 selection = gtk_tree_view_get_selection(treeview_);
 scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
 gtk_widget_show(scrolledwindow);
 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolledwindow),
           GTK_SHADOW_ETCHED_IN);
 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
           GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
 gtk_container_add(GTK_CONTAINER(scrolledwindow), GTK_WIDGET(treeview_));
 return scrolledwindow;
}
/* Widget Sequence:
 * clear_button,
 * WordCombo
 */
static void topwin_create(GtkWidget *vbox)
{
 GtkWidget *hbox = gtk_hbox_new(FALSE, FALSE);
 GtkWidget *button, *WordCombo;
 GtkListStore *list_store;
 gtk_widget_show(hbox);
 gtk_box_pack_start(GTK_BOX(vbox),hbox,0,0,3);
 
 /* first - clear */
 button = gtk_button_new();
 gtk_container_add(GTK_CONTAINER(button),gtk_image_new_from_stock(GTK_STOCK_UNDO,GTK_ICON_SIZE_BUTTON));
 gtk_widget_show_all(button);
 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
 GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
 gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 0);
 /* second - input and .. */
 list_store = gtk_list_store_new(1, G_TYPE_STRING);
 WordCombo = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(list_store), 0);
 g_object_unref(G_OBJECT(list_store));
 gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(WordCombo), FALSE);
 gtk_container_forall(GTK_CONTAINER(WordCombo), unfocus_combo_arrow, NULL);
 gtk_widget_set_size_request(WordCombo, 60, -1);
 gtk_widget_show(WordCombo);
 gtk_entry_set_max_length(GTK_ENTRY(GTK_BIN(WordCombo)->child), 255);
 g_signal_connect(G_OBJECT(GTK_BIN(WordCombo)->child), "changed",
     G_CALLBACK(input_words), NULL);
 gtk_box_pack_start(GTK_BOX(hbox),WordCombo, TRUE, TRUE, 3);
 /* third */
 button = gtk_button_new();
 gtk_container_add(GTK_CONTAINER(button),gtk_image_new_from_stock(GTK_STOCK_HOME,GTK_ICON_SIZE_BUTTON));
 gtk_widget_show_all(button);
 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
 gtk_box_pack_start(GTK_BOX(hbox),button,0,0,0);
}
static void midwin_create(GtkWidget *vbox)
{
 GtkWidget *vbox1, *hbox, *hpaned;
 hbox = gtk_hbox_new(FALSE, 2);
 hpaned = gtk_hpaned_new();
 gtk_widget_show(hpaned);
 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0);
 /**/
 indexwin_create(hpaned);
 
 vbox1 = gtk_vbox_new(FALSE, 0);
 gtk_widget_show(vbox1);
 textwin_create(vbox1);
 gtk_paned_pack2(GTK_PANED(hpaned), vbox1, TRUE, FALSE);
}
static void bottomwin_create(GtkWidget *vbox)
{
 topwin_create(vbox);
}
static GtkWidget *build_window(void)
{
 GtkWidget *window = NULL;
 /* FIXME: here need check SUCCESS? */
 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window), soft_prog);
 gtk_window_set_default_size(GTK_WINDOW(window),
  GRAH_DEFAULT_WIN_WIDTH, GRAH_DEFAULT_WIN_HEIGTH);
 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 return window;
}
static void add_widget_to_window(GtkWidget *window, GtkWidget *widget)
{
 gtk_container_add(GTK_CONTAINER(window), widget);
}
/* Our main vbox has 3 parts: Top / Mid / Bottom.
 * main vbox is belong to main window.
 */
static GtkWidget *build_main_vbox(void)
{
 GtkWidget *box;
 box = gtk_vbox_new(FALSE,0);
 topwin_create(box);
 midwin_create(box);
 bottomwin_create(box);
 return box;
}
/* Build a core window with default setting the vbox. */
GtkWidget *build_main_window(void)
{
 GtkWidget *vbox, *window;
 vbox = build_main_vbox();
 window = build_window();
 assert(window && vbox);
 add_widget_to_window(window, vbox);
 return window;
}           界面就这一个文件。 调用最下面的 build_main_window 就可以了
搜索更多相关主题的帖子: 界面 
2008-09-30 22:09
奔跑的鸟
Rank: 1
等 级:新手上路
帖 子:391
专家分:0
注 册:2006-1-20
收藏
得分:0 
介个。。。绘制窗口。。。?

简单的快乐着~
2008-09-30 22:14
HAN2008
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2008-9-21
收藏
得分:0 
请详细
2008-09-30 22:16
奔跑的鸟
Rank: 1
等 级:新手上路
帖 子:391
专家分:0
注 册:2006-1-20
收藏
得分:0 
我汗,我还以为是让我们观摩学习的,原来你的意思是让帮你解释是么

简单的快乐着~
2008-09-30 22:24
HAN2008
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2008-9-21
收藏
得分:0 
不朋友写的 他想让界面美 想改下 ........ 所以叫你详细改下
2008-09-30 22:34
快速回复:调节界面求
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021927 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved