亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gtk_tut-13.html

?? GTK development guide
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
 <TITLE>GTK v1.2 Tutorial: Menu Widget</TITLE>
 <LINK HREF="gtk_tut-14.html" REL=next>
 <LINK HREF="gtk_tut-12.html" REL=previous>
 <LINK HREF="gtk_tut.html#toc13" REL=contents>
</HEAD>
<BODY TEXT="#CCCCCC" BGCOLOR="#000000" LINK="#33cc00" VLINK="#009900" ALINK="#FF0000">
<A HREF="gtk_tut-14.html">Next</A>
<A HREF="gtk_tut-12.html">Previous</A>
<A HREF="gtk_tut.html#toc13">Contents</A>
<HR>
<H2><A NAME="s13">13. Menu Widget</A></H2>

<P>There are two ways to create menus: there's the easy way, and there's
the hard way. Both have their uses, but you can usually use the
Itemfactory (the easy way). The "hard" way is to create all the menus
using the calls directly. The easy way is to use the gtk_item_factory
calls. This is much simpler, but there are advantages and
disadvantages to each approach.
<P>The Itemfactory is much easier to use, and to add new menus to,
although writing a few wrapper functions to create menus using the
manual method could go a long way towards usability. With the
Itemfactory, it is not possible to add images or the character '/' to
the menus.
<P>
<H2><A NAME="ss13.1">13.1 Manual Menu Creation</A>
</H2>

<P>In the true tradition of teaching, we'll show you the hard way
first. <CODE>:)</CODE>
<P>There are three widgets that go into making a menubar and submenus:
<UL>
<LI>a menu item, which is what the user wants to select, e.g.,
"Save"</LI>
<LI>a menu, which acts as a container for the menu items, and</LI>
<LI>a menubar, which is a container for each of the individual
menus.</LI>
</UL>
<P>This is slightly complicated by the fact that menu item widgets are
used for two different things. They are both the widgets that are
packed into the menu, and the widget that is packed into the menubar,
which, when selected, activates the menu.
<P>Let's look at the functions that are used to create menus and
menubars.  This first function is used to create a new menubar.
<P>
<BLOCKQUOTE><CODE>
<PRE>
GtkWidget *gtk_menu_bar_new( void );
</PRE>
</CODE></BLOCKQUOTE>
<P>This rather self explanatory function creates a new menubar. You use
gtk_container_add to pack this into a window, or the box_pack
functions to pack it into a box - the same as buttons.
<P>
<BLOCKQUOTE><CODE>
<PRE>
GtkWidget *gtk_menu_new( void );
</PRE>
</CODE></BLOCKQUOTE>
<P>This function returns a pointer to a new menu; it is never actually
shown (with gtk_widget_show), it is just a container for the menu
items. I hope this will become more clear when you look at the
example below.
<P>The next two calls are used to create menu items that are packed into
the menu (and menubar).
<P>
<BLOCKQUOTE><CODE>
<PRE>
GtkWidget *gtk_menu_item_new( void );
</PRE>
</CODE></BLOCKQUOTE>
<P>and
<P>
<BLOCKQUOTE><CODE>
<PRE>
GtkWidget *gtk_menu_item_new_with_label( const char *label );
</PRE>
</CODE></BLOCKQUOTE>
<P>These calls are used to create the menu items that are to be
displayed.  Remember to differentiate between a "menu" as created with
gtk_menu_new and a "menu item" as created by the gtk_menu_item_new
functions. The menu item will be an actual button with an associated
action, whereas a menu will be a container holding menu items.
<P>The gtk_menu_new_with_label and gtk_menu_new functions are just as
you'd expect after reading about the buttons. One creates a new menu
item with a label already packed into it, and the other just creates a
blank menu item.
<P>Once you've created a menu item you have to put it into a menu. This
is done using the function gtk_menu_append. In order to capture when
the item is selected by the user, we need to connect to the
<CODE>activate</CODE> signal in the usual way. So, if we wanted to create a
standard <CODE>File</CODE> menu, with the options <CODE>Open</CODE>, <CODE>Save</CODE>, and
<CODE>Quit</CODE>, the code would look something like:
<P>
<BLOCKQUOTE><CODE>
<PRE>
    file_menu = gtk_menu_new ();    /* Don't need to show menus */

    /* Create the menu items */
    open_item = gtk_menu_item_new_with_label ("Open");
    save_item = gtk_menu_item_new_with_label ("Save");
    quit_item = gtk_menu_item_new_with_label ("Quit");

    /* Add them to the menu */
    gtk_menu_append (GTK_MENU (file_menu), open_item);
    gtk_menu_append (GTK_MENU (file_menu), save_item);
    gtk_menu_append (GTK_MENU (file_menu), quit_item);

    /* Attach the callback functions to the activate signal */
    gtk_signal_connect_object (GTK_OBJECT (open_items), "activate",
                               GTK_SIGNAL_FUNC (menuitem_response),
                               (gpointer) "file.open");
    gtk_signal_connect_object (GTK_OBJECT (save_items), "activate",
                               GTK_SIGNAL_FUNC (menuitem_response),
                               (gpointer) "file.save");

    /* We can attach the Quit menu item to our exit function */
    gtk_signal_connect_object (GTK_OBJECT (quit_items), "activate",
                               GTK_SIGNAL_FUNC (destroy),
                               (gpointer) "file.quit");

    /* We do need to show menu items */
    gtk_widget_show (open_item);
    gtk_widget_show (save_item);
    gtk_widget_show (quit_item);
</PRE>
</CODE></BLOCKQUOTE>
<P>At this point we have our menu. Now we need to create a menubar and a
menu item for the <CODE>File</CODE> entry, to which we add our menu. The code
looks like this:
<P>
<BLOCKQUOTE><CODE>
<PRE>
    menu_bar = gtk_menu_bar_new ();
    gtk_container_add (GTK_CONTAINER (window), menu_bar);
    gtk_widget_show (menu_bar);

    file_item = gtk_menu_item_new_with_label ("File");
    gtk_widget_show (file_item);
</PRE>
</CODE></BLOCKQUOTE>
<P>Now we need to associate the menu with <CODE>file_item</CODE>. This is done
with the function
<P>
<BLOCKQUOTE><CODE>
void gtk_menu_item_set_submenu( GtkMenuItem *menu_item,
GtkWidget   *submenu );
</CODE></BLOCKQUOTE>
<P>So, our example would continue with
<P>
<BLOCKQUOTE><CODE>
<PRE>
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item), file_menu);
</PRE>
</CODE></BLOCKQUOTE>
<P>All that is left to do is to add the menu to the menubar, which is
accomplished using the function
<P>
<BLOCKQUOTE><CODE>
void gtk_menu_bar_append( GtkMenuBar *menu_bar,
GtkWidget  *menu_item );
</CODE></BLOCKQUOTE>
<P>which in our case looks like this:
<P>
<BLOCKQUOTE><CODE>
<PRE>
    gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), file_item);
</PRE>
</CODE></BLOCKQUOTE>
<P>If we wanted the menu right justified on the menubar, such as help
menus often are, we can use the following function (again on
<CODE>file_item</CODE> in the current example) before attaching it to the
menubar.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void gtk_menu_item_right_justify( GtkMenuItem *menu_item );
</PRE>
</CODE></BLOCKQUOTE>
<P>Here is a summary of the steps needed to create a menu bar with menus
attached:
<P>
<UL>
<LI> Create a new menu using gtk_menu_new()</LI>
<LI> Use multiple calls to gtk_menu_item_new() for each item you
wish to have on your menu. And use gtk_menu_append() to put each of
these new items on to the menu.</LI>
<LI> Create a menu item using gtk_menu_item_new(). This will be the
root of the menu, the text appearing here will be on the menubar
itself.</LI>
<LI>Use gtk_menu_item_set_submenu() to attach the menu to the root
menu item (the one created in the above step).</LI>
<LI> Create a new menubar using gtk_menu_bar_new. This step only
needs to be done once when creating a series of menus on one menu bar.</LI>
<LI> Use gtk_menu_bar_append() to put the root menu onto the menubar.</LI>
</UL>
<P>Creating a popup menu is nearly the same. The difference is that the
menu is not posted "automatically" by a menubar, but explicitly by
calling the function gtk_menu_popup() from a button-press event, for
example.  Take these steps:
<P>
<UL>
<LI>Create an event handling function. It needs to have the
prototype
<BLOCKQUOTE><CODE>
static gint handler (GtkWidget *widget,
GdkEvent  *event);
</CODE></BLOCKQUOTE>

and it will use the event to find out where to pop up the menu.</LI>
<LI>In the event handler, if the event is a mouse button press,
treat <CODE>event</CODE> as a button event (which it is) and use it as
shown in the sample code to pass information to gtk_menu_popup().</LI>
<LI>Bind that event handler to a widget with
<BLOCKQUOTE><CODE>
gtk_signal_connect_object (GTK_OBJECT (widget), "event",
GTK_SIGNAL_FUNC (handler),
GTK_OBJECT (menu));
</CODE></BLOCKQUOTE>

where <CODE>widget</CODE> is the widget you are binding to,
<CODE>handler</CODE> is the handling function, and <CODE>menu</CODE> is a menu
created with gtk_menu_new(). This can be a menu which is also posted
by a menu bar, as shown in the sample code.</LI>
</UL>
<P>
<H2><A NAME="ss13.2">13.2 Manual Menu Example</A>
</H2>

<P>That should about do it. Let's take a look at an example to help clarify.
<P>
<BLOCKQUOTE><CODE>
<PRE>
/* example-start menu menu.c */

#include &lt;stdio.h>
#include &lt;gtk/gtk.h>

static gint button_press (GtkWidget *, GdkEvent *);
static void menuitem_response (gchar *);

int main( int   argc,
          char *argv[] )
{

    GtkWidget *window;
    GtkWidget *menu;
    GtkWidget *menu_bar;
    GtkWidget *root_menu;
    GtkWidget *menu_items;
    GtkWidget *vbox;
    GtkWidget *button;
    char buf[128];
    int i;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产99一区视频免费| 视频一区视频二区在线观看| 日韩欧美精品在线| 欧美夫妻性生活| 51精品久久久久久久蜜臀| 欧美久久久久久蜜桃| 欧美日韩成人激情| 日韩视频一区二区| 欧美电影免费观看完整版| 26uuu国产电影一区二区| 久久精品免视看| 国产精品久久久久久久岛一牛影视 | 亚洲成人激情综合网| 亚洲午夜一区二区| 三级不卡在线观看| 美女视频黄a大片欧美| 极品少妇一区二区| 成人一区二区三区在线观看| 99久久亚洲一区二区三区青草| 色呦呦国产精品| 8x8x8国产精品| 26uuu另类欧美亚洲曰本| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美激情在线一区二区| 亚洲欧美影音先锋| 午夜精品久久久久久久| 精品亚洲免费视频| av一区二区三区四区| 欧美日韩视频在线观看一区二区三区 | 亚洲免费观看高清完整版在线| 亚洲三级理论片| 天天综合网天天综合色| 国产福利视频一区二区三区| k8久久久一区二区三区| 在线电影一区二区三区| 国产精品视频第一区| 日韩和欧美一区二区三区| 国产精品一区二区免费不卡| 在线视频欧美精品| 久久综合狠狠综合久久综合88| 亚洲图片另类小说| 国产精品一区免费在线观看| 欧美日韩亚洲综合在线| 亚洲国产精品高清| 久久成人免费电影| 日本黄色一区二区| 久久久久久一级片| 日韩电影一二三区| 色婷婷综合久色| 欧美国产一区视频在线观看| 另类小说视频一区二区| 欧美私模裸体表演在线观看| 国产精品福利一区二区三区| 激情五月婷婷综合| 欧美一区二区三区精品| 夜夜揉揉日日人人青青一国产精品| 国产精品538一区二区在线| 在线成人免费观看| 一区二区三区中文在线| 99精品视频免费在线观看| 久久一区二区三区四区| 久久99久久久欧美国产| 日韩欧美电影在线| 天天综合日日夜夜精品| 欧美日韩免费观看一区三区| 亚洲精品欧美二区三区中文字幕| 成人精品国产福利| 国产精品久久毛片| 99re这里都是精品| 中文字幕一区不卡| 9l国产精品久久久久麻豆| 国产女主播视频一区二区| 国产精品一二三区在线| 国产人伦精品一区二区| 国产成人精品免费网站| 久久久综合激的五月天| 国产91精品久久久久久久网曝门| 国产欧美精品日韩区二区麻豆天美| 国内外成人在线视频| 国产亚洲一区字幕| 成人免费黄色在线| 亚洲欧美一区二区不卡| 在线视频国内自拍亚洲视频| 亚洲第一主播视频| 91精品国产91综合久久蜜臀| 看电视剧不卡顿的网站| 久久精品一区二区三区不卡牛牛 | 一级精品视频在线观看宜春院 | 亚洲欧洲成人精品av97| 成人avav影音| 亚洲免费在线视频| 欧美日韩久久不卡| 美女尤物国产一区| 日本一区二区免费在线观看视频| 99精品国产视频| 日韩av在线发布| 中文文精品字幕一区二区| 99国产精品久| 三级在线观看一区二区| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品白丝jk白祙喷水网站| 亚洲品质自拍视频| 91精品国产综合久久蜜臀| 国产精品亚洲成人| 亚洲已满18点击进入久久| 日韩一区和二区| 99久久免费精品高清特色大片| 日韩影院免费视频| 中文字幕欧美日韩一区| 欧美日韩夫妻久久| 丁香桃色午夜亚洲一区二区三区| 亚洲免费看黄网站| 精品国产乱码久久久久久1区2区| 91免费精品国自产拍在线不卡| 蜜臀久久久99精品久久久久久| 国产精品麻豆久久久| 337p亚洲精品色噜噜狠狠| 成人免费福利片| 精品一区二区免费视频| 一区二区三区中文免费| 国产清纯白嫩初高生在线观看91 | 欧美日韩一区二区不卡| 成人av电影在线| 久久精品噜噜噜成人88aⅴ| 亚洲另类春色国产| 欧美国产精品劲爆| 日韩视频永久免费| 精品视频1区2区3区| 色综合久久88色综合天天| 国产成人免费视| 久久成人久久爱| 视频一区国产视频| 亚洲主播在线观看| 亚洲日本一区二区| 国产精品美日韩| 国产日韩影视精品| 久久综合九色欧美综合狠狠| 日韩亚洲欧美在线| 欧美日韩国产天堂| 欧美最猛性xxxxx直播| 9i看片成人免费高清| 国产91富婆露脸刺激对白| 国产麻豆成人精品| 精品一区二区在线免费观看| 免费成人av在线播放| 偷拍日韩校园综合在线| 午夜不卡av在线| 亚洲va国产天堂va久久en| 亚洲风情在线资源站| 亚洲第一激情av| 午夜激情久久久| 奇米影视在线99精品| 久久精品国产精品青草| 蜜臀a∨国产成人精品| 麻豆91免费观看| 国内精品自线一区二区三区视频| 狠狠狠色丁香婷婷综合久久五月| 久久精品国产**网站演员| 久久69国产一区二区蜜臀 | 日本一区二区视频在线| 久久久久久麻豆| 国产欧美精品一区aⅴ影院 | 欧日韩精品视频| 欧美日韩一区二区三区不卡| 777亚洲妇女| 精品美女被调教视频大全网站| 精品99久久久久久| 久久久99精品免费观看| 18成人在线观看| 亚洲电影一级黄| 国产真实精品久久二三区| 国产麻豆精品一区二区| 91影院在线免费观看| 7777精品久久久大香线蕉| 91精品国产综合久久久久久漫画 | 中文字幕亚洲不卡| 亚洲国产日韩av| 久久99这里只有精品| 成人av资源站| 欧美日韩久久一区| 久久久综合网站| 亚洲午夜精品17c| 经典三级视频一区| 99re视频精品| 精品国内二区三区| 亚洲人成在线播放网站岛国| 奇米777欧美一区二区| 成人黄色777网| 91精品国产综合久久久久久| 国产午夜精品一区二区三区嫩草| 亚洲精品成人悠悠色影视| 久久www免费人成看片高清| 成人av电影在线观看| 欧美一区二区福利视频| 最新热久久免费视频| 精品影视av免费| 欧美理论在线播放| 国产精品国产三级国产普通话99| 美女国产一区二区三区| 在线这里只有精品|