亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
精品亚洲porn| 欧亚洲嫩模精品一区三区| 精品入口麻豆88视频| 日韩经典一区二区| 欧美日韩在线精品一区二区三区激情| 综合av第一页| caoporen国产精品视频| 欧美激情在线观看视频免费| 激情欧美一区二区三区在线观看| 日韩一级大片在线| 久久精品99国产精品| 91精品国产综合久久久久久| 日韩中文字幕亚洲一区二区va在线| 欧美日韩你懂的| 日韩中文字幕av电影| 欧美一区二区三区在线视频| 奇米色一区二区| 日韩欧美中文一区| 久久不见久久见免费视频7| 精品美女被调教视频大全网站| 久久99国产精品麻豆| 精品国产一区二区三区久久影院| 激情综合色综合久久综合| 欧美精品一区二区三| 九一久久久久久| 久久免费看少妇高潮| 国产激情一区二区三区四区| 欧美国产禁国产网站cc| 99久久国产综合精品色伊| 一区二区三区高清在线| 欧美艳星brazzers| 日本亚洲一区二区| 久久综合网色—综合色88| 处破女av一区二区| 亚洲精品国产品国语在线app| 欧美日韩国产精选| 蜜臀久久久99精品久久久久久| 2欧美一区二区三区在线观看视频| 国产在线精品一区二区三区不卡 | 久久奇米777| 波多野结衣精品在线| 亚洲欧美精品午睡沙发| 欧美色综合影院| 久久福利资源站| 国产精品色在线观看| 在线观看亚洲a| 麻豆精品蜜桃视频网站| 中文字幕欧美国产| 欧美性生交片4| 激情六月婷婷久久| 亚洲欧美aⅴ...| 欧美精品丝袜久久久中文字幕| 久久成人久久爱| 亚洲人成电影网站色mp4| 7777精品伊人久久久大香线蕉| 国产乱妇无码大片在线观看| 亚洲欧洲综合另类| 欧美成人video| 99re热这里只有精品免费视频| 亚洲狠狠爱一区二区三区| 26uuu亚洲| 色婷婷久久99综合精品jk白丝| 视频一区二区三区在线| 国产日韩精品久久久| 在线观看亚洲一区| 国产做a爰片久久毛片| 亚洲男人天堂av网| 欧美成人女星排名| 91亚洲国产成人精品一区二三| 亚洲国产精品久久艾草纯爱| 久久综合色鬼综合色| 色综合天天做天天爱| 九九久久精品视频| 一区二区三区成人| 久久你懂得1024| 欧美理论在线播放| 成人美女在线视频| 久久成人免费日本黄色| 一区二区免费在线播放| 久久这里只有精品6| 欧美吻胸吃奶大尺度电影| 激情小说欧美图片| 亚洲在线观看免费视频| 久久青草欧美一区二区三区| 欧美色综合久久| caoporen国产精品视频| 精品午夜久久福利影院| 一区二区成人在线| 欧美国产日本视频| 精品国产欧美一区二区| 在线观看www91| 成人免费视频免费观看| 看国产成人h片视频| 亚洲综合成人在线| 国产精品青草综合久久久久99| 日韩免费观看高清完整版| 日本乱人伦一区| 成人精品免费视频| 国产一区二区三区久久久| 日韩电影在线一区二区三区| 亚洲精品免费在线播放| 精品国产电影一区二区| 91精品免费在线| 欧美三级电影一区| 91看片淫黄大片一级在线观看| 国产乱对白刺激视频不卡| 奇米影视在线99精品| 亚洲成人在线网站| 亚洲一区在线播放| 亚洲欧美日韩系列| 亚洲欧美自拍偷拍| 国产亚洲va综合人人澡精品 | 在线免费观看日本欧美| 成人ar影院免费观看视频| 国内成+人亚洲+欧美+综合在线 | 亚洲免费在线看| 日韩一区在线看| 国产精品久久久久三级| 欧美激情中文不卡| 国产日韩影视精品| 国产亚洲精品bt天堂精选| 久久久久久久久久久久久久久99| 日韩欧美国产一区二区在线播放| 777奇米四色成人影色区| 欧美人xxxx| 欧美日本在线视频| 欧美精品久久99久久在免费线| 欧美三级乱人伦电影| 欧美日韩久久久| 欧美日韩高清一区二区三区| 欧美日韩国产综合久久| 欧美精品视频www在线观看| 欧美色图在线观看| 欧美精品乱码久久久久久| 91精品国产综合久久精品app| 555夜色666亚洲国产免| 911精品国产一区二区在线| 538prom精品视频线放| 日韩一区二区在线观看视频播放| 欧美一区二区三区视频免费播放 | 久久久久亚洲蜜桃| 久久精品人人做| 国产精品视频yy9299一区| 国产精品久久久久天堂| 亚洲欧美日韩中文播放| 亚洲综合在线免费观看| 亚洲chinese男男1069| 日本vs亚洲vs韩国一区三区二区| 麻豆国产精品官网| 国产激情一区二区三区| 99久久久免费精品国产一区二区| 91蜜桃在线免费视频| 欧美日韩综合在线| 欧美一区二区在线免费观看| 精品国产乱码久久久久久久 | 午夜伦欧美伦电影理论片| 日韩va亚洲va欧美va久久| 美日韩一级片在线观看| 国产精品自拍网站| 99v久久综合狠狠综合久久| 色国产综合视频| 91精品国产一区二区| 欧美精彩视频一区二区三区| 亚洲欧美激情小说另类| 日本aⅴ免费视频一区二区三区| 国产麻豆精品95视频| 91在线视频在线| 欧美电影一区二区三区| 久久免费视频色| 一区二区三区中文在线观看| 日韩成人午夜精品| 国产成a人亚洲| 欧美综合欧美视频| 精品动漫一区二区三区在线观看| 国产精品美女久久久久aⅴ| 亚洲国产乱码最新视频| 免费xxxx性欧美18vr| 国产99久久久国产精品| 色噜噜狠狠成人中文综合 | 欧美一区二区三区四区在线观看| 国产亚洲精品资源在线26u| 一级精品视频在线观看宜春院 | 亚洲人123区| 蜜臀av一级做a爰片久久| 成人深夜福利app| 91精品国产欧美日韩| 国产精品人成在线观看免费| 婷婷开心激情综合| 成人福利视频在线| 777亚洲妇女| 亚洲欧洲日本在线| 另类小说一区二区三区| aa级大片欧美| 日韩欧美中文一区| 一区二区三区日韩欧美| 国产乱码精品一区二区三区五月婷 | 成人看片黄a免费看在线| 欧美日韩高清在线播放| 国产精品久久福利| 麻豆国产精品官网|