📄 z207.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> Widgets </title> <meta name="GENERATOR" content= "Modular DocBook HTML Stylesheet Version 1.45"> <link rel="HOME" title="GTK+ / Gnome Application Development" href="ggad.html"> <link rel="UP" title="GTK+/Gnome Object Hierarchy" href= "hierarchy.html"> <link rel="PREVIOUS" title="GtkObject" href="z202.html"> <link rel="NEXT" title="Canvas Items" href="z736.html"> </head> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink= "#840084" alink="#0000FF"> <div class="NAVHEADER"> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <th colspan="4" align="center"> <font color="#000000" size="2">GTK+ / Gnome Application Development</font> </th> </tr> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="z202.html"><font color="#0000ff" size="2"><b> <<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z736.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> </table> </div> <div class="SECT1"> <h1 class="SECT1"> <a name="Z207">Widgets</a> </h1> <p> <i class="FIRSTTERM">Widgets</i> are the reason for GTK+'s existence. Widgets are subclasses of <tt class="CLASSNAME"> GtkWidget</tt>, which is in turn a subclass of <span class= "STRUCTNAME">GtkObject</span>. A widget represents a rectangular region on the screen, and may be purely decorative, an interactive control, or a container controlling the arrangement of child widgets. <a href= "cha-gtk.html">the chapter called <i>GTK+ Basics</i></a> introduces GTK+ and thus widgets; <a href= "cha-widget.html">the chapter called <i>Writing a <tt class="CLASSNAME">GtkWidget</tt></i></a> covers widget implementation and concepts in more detail. </p> <div class="SECT2"> <h2 class="SECT2"> <a name="Z208"><tt class="CLASSNAME">GtkWidget</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z209">Library</a> </h3> <p> GTK+ </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z210">Header File</a> </h3> <p> <tt class="FILENAME">gtk/gtkwidget.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z211">Description</a> </h3> <p> <tt class="CLASSNAME">GtkWidget</tt> is the parent class of all widgets. Chapters <a href="cha-gtk.html"> the chapter called <i>GTK+ Basics</i></a> and <a href= "cha-widget.html">the chapter called <i>Writing a <tt class="CLASSNAME">GtkWidget</tt></i></a> describe widgets in general terms. </p> <p> <tt class="CLASSNAME">GtkWidget</tt> is an abstract base class. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z212"><tt class="CLASSNAME"> GtkContainer</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z213">Library</a> </h3> <p> GTK+ </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z214">Header File</a> </h3> <p> <tt class="FILENAME">gtk/gtkcontainer.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z215">Description</a> </h3> <p> <tt class="CLASSNAME">GtkContainer</tt> is the abstract base class for widgets that can contain other widgets. <a href="sec-containers.html">the section called <i> Containers And Widget Layout</i> in the chapter called <i>GTK+ Basics</i></a> describes containers in some detail; <a href="cha-widget.html">the chapter called <i>Writing a <tt class="CLASSNAME"> GtkWidget</tt></i></a> includes information on container widget implementation. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z216"><tt class="CLASSNAME">GtkBin</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z217">Library</a> </h3> <p> GTK+ </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z218">Header File</a> </h3> <p> <tt class="FILENAME">gtk/gtkbin.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z219">Description</a> </h3> <p> <tt class="CLASSNAME">GtkBin</tt> is an abstract base class for containers with one child. It provides default implementions of the <tt class="CLASSNAME"> GtkContainer</tt> interface, so it is very easy to subclass. <a href="cha-widget.html">the chapter called <i>Writing a <tt class="CLASSNAME"> GtkWidget</tt></i></a> describes how to implement a <tt class="CLASSNAME">GtkBin</tt> subclass. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z220"><tt class="CLASSNAME">GtkWindow</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z221">Library</a> </h3> <p> GTK+ </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z222">Header File</a> </h3> <p> <tt class="FILENAME">gtk/gtkwindow.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z223">Description</a> </h3> <p> <tt class="CLASSNAME">GtkWindow</tt> represents a toplevel dialog or application window. As the primary toplevel widget in GTK+, it has many special responsibilities; for example, it maintains the current keyboard focus and determines its own size allocation (rather than receiving one from a parent widget). </p> <p> Gnome applications typically use <tt class="CLASSNAME"> GnomeApp</tt> for main application windows, to take advantage of its added features; for dialogs, you should use <tt class="CLASSNAME">GnomeDialog</tt> with Gnome and <tt class="CLASSNAME">GtkDialog</tt> with GTK+. Of course there are several specialized dialog subclasses available as well. If none of <tt class= "CLASSNAME">GtkWindow</tt>'s subclasses seem appropriate to your application, <tt class="CLASSNAME"> GtkWindow</tt> can also be used directly. </p> <p> A danger worthy of note: <tt class="CLASSNAME"> GtkWindow</tt> is automatically destroyed if it receives a <span class="SYMBOL">"delete_event"</span> signal. To prevent this, you must install the <i class= "EMPHASIS">last</i> signal handler to run, and your signal handler must return <span class="STRUCTNAME"> TRUE</span>. This is a very common GTK+ programming mistake; see <a href= "sec-gdkevent.html#SEC-WINDOWCHANGEEVENTS">the section called <i>Window Change Events</i> in the chapter called <i>GDK Basics</i></a> for details. <tt class= "CLASSNAME">GnomeDialog</tt> will help you handle this situation; see <a href="cha-dialogs.html">the chapter called <i>User Communication: Dialogs</i></a>. </p> <p> It is a good idea to make <tt class="CLASSNAME"> GtkWindow</tt> the last container you call <tt class= "FUNCTION">gtk_widget_show()</tt> on. Most widgets are not actually mapped (placed onscreen) until their parent container is; but <tt class="CLASSNAME"> GtkWindow</tt> has no parent, and appears immediately. So if you show its children after you've shown the window, you will see some flicker. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z224"><tt class="CLASSNAME">GnomeDialog</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z225">Library</a> </h3> <p> Gnome </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z226">Header File</a> </h3> <p> <tt class="FILENAME">libgnomeui/gnome-dialog.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z227">Description</a> </h3> <p> <tt class="CLASSNAME">GnomeDialog</tt> (or a subclass) should be used for all dialogs in a Gnome program. <a href="cha-dialogs.html">the chapter called <i>User Communication: Dialogs</i></a> describes the <tt class= "CLASSNAME">GnomeDialog</tt> interface. </p> <p> If you aren't using Gnome, <tt class="CLASSNAME"> GnomeDialog</tt> is still useful --- because it implements all the basic features a dialog really must have. Studying the <tt class="CLASSNAME"> GnomeDialog</tt> source is highly recommended (you can even cut-and-paste if your application is under the GPL). </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z228"><tt class="CLASSNAME">GnomeAbout</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z229">Library</a> </h3> <p> Gnome </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z230">Header File</a> </h3> <p> <tt class="FILENAME">libgnomeui/gnome-about.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z231">Description</a> </h3> <p> <tt class="CLASSNAME">GnomeAbout</tt> is an about dialog, giving Gnome about dialogs a consistent look-and-feel. <a href= "cha-dialogs-special.html#SEC-GNOMEABOUT">the section called <i><tt class="CLASSNAME">GnomeAbout</tt></i> in the chapter called <i>User Communication: Dialogs</i></a> covers the interface. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z232"><tt class="CLASSNAME"> GnomeMessageBox</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z233">Library</a> </h3> <p> Gnome </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z234">Header File</a> </h3> <p> <tt class="FILENAME">libgnomeui/gnome-messagebox.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z235">Description</a> </h3> <p> <tt class="CLASSNAME">GnomeMessageBox</tt> is simply a <tt class="CLASSNAME">GnomeDialog</tt> with a label and a small icon pre-packed inside. The icon corresponds to a "message box type," such as a warning message, an error, or a question. This helps users rapidly determine the dialog's purpose. <a href= "cha-dialogs-special.html#SEC-MESSAGEBOX">the section called <i><tt class="CLASSNAME"> GnomeMessageBox</tt></i> in the chapter called <i>User Communication: Dialogs</i></a> explains the use of this widget. </p> </div> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z236"><tt class="CLASSNAME"> GnomePropertyBox</tt></a> </h2> <div class="SECT3"> <h3 class="SECT3"> <a name="Z237">Library</a> </h3> <p> Gnome </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z238">Header File</a> </h3> <p> <tt class="FILENAME"> libgnomeui/gnome-propertybox.h</tt> </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z239">Description</a> </h3> <p> <tt class="CLASSNAME">GnomePropertyBox</tt> is a dialog for application preferences or the properties of some user-visible object in your program. It has "apply", "OK", "close", and "help" buttons; "OK" is equivalent to "apply" followed by "close." <a href= "cha-dialogs-special.html#SEC-PROPERTYBOX">the section called <i><tt class="CLASSNAME"> GnomePropertyBox</tt></i> in the chapter called <i>User
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -