⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtk.texi

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
\input texinfo @c -*-texinfo-*-@c Copyright (C) 1996 by Peter Mattis. All rights reserved.@c Portions Copyright (C) 1998 Marius Vollmer@c@c %**start of header@setfilename gtk.info@settitle GTK@setchapternewpage odd@include macros.texi@c %**end of header@set edition 1.0@set update-date 23 August 1998@set update-month August 1998@ifinfoThis file documents GTK, the GIMP ToolkitCopyright (C) 1996 Peter MattisCopyright (C) 1997 Peter MattisPermission is granted to make and distribute verbatim copies of thismanual provided the copyright notice and this permission notice arepreserved on all copies@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries copying permission noticeidentical to this one except for the removal of this paragraph (thisparagraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that theentire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translationapproved by Peter Mattis.@end ifinfo@titlepage@title The GIMP Toolkit@subtitle Version @value{edition}@subtitle @value{update-month}@author by Peter Mattis and the GTK+ team@page@vskip 0pt plus 1filllCopyright @copyright{} 1996 Peter Mattis@vskip 0pt plus 1fillCopyright @copyright{} 1997 Peter MattisPermission is granted to make and distribute verbatim copies of thismanual provided the copyright notice and this permission notice arepreserved on all copies.Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that theentire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translationapproved by Peter Mattis.@end titlepage@dircategory User Interface Toolkit@direntry* GTK: (gtk).		The GIMP Toolkit@end direntry@node Top, Copying, (dir), (dir)@top The GIMP Toolkit@ifinfoThis is edition @value{edition} of the GTK documentation,@w{@value{update-date}}.@end ifinfo@c FIXME: Do a introduction to the GTK?@menu* Copying::                     Your rights.* Overview::                    What is GTK?* Types::                       * Objects::                     * Signals::                     Signals overview.* Widgets::                     Widget overview.* Other Objects::               Utility objects.* Miscellaneous::               Initialization, exit and other features.* Examples::                    Using GTK.* Object Implementation::       Object internals.* Signal Implementation::       Signal internals.* Widget Implementation::       Widget internals.* Function Index::              Index of functions.* Concept Index::               Index of concepts.@end menu@node Copying, Overview, Top, Top@comment node-name, next, previous, up@chapter Copying@cindex CopyingGTK is @dfn{free}; this means that everyone is free to use it and freeto redistribute it on a free basis. GTK is not in the public domain; itis copyrighted and there are restrictions on its distribution, butthese restrictions are designed to permit everything that a goodcooperating citizen would want to do. What is not allowed is to try toprevent others from further sharing any version of GTK that they mightget from you.Specifically, we want to make sure that you have the right to give awaycopies of GTK, that you receive source code or else can get it if youwant it, that you can change GTK or use pieces of it in new freeprograms, and that you know you can do these things.To make sure that everyone has such rights, we have to forbid you todeprive anyone else of these rights. For example, if you distributecopies of GTK, you must give the recipients all the rights that youhave. You must make sure that they, too, receive or can get the sourcecode. And you must tell them their rights.Also, for our own protection, we must make certain that everyone findsout that there is no warranty for GTK. If GTK is modified by someoneelse and passed on, we want their recipients to know that what they haveis not what we distributed, so that any problems introduced by otherswill no reflect on our reputation.The precise conditions of the licenses for GTK are found in the GeneralPublic Licenses that accompany it.@node Overview, Types, Copying, Top@comment node-name, next, previous, up@chapter What is GTK?@cindex OverviewGTK is a library for creating graphical user interfaces similar to theMotif ``look and feel''. It is designed to be small and efficient, butstill flexible enough to allow the programmer freedom in the interfacescreated. GTK allows the programmer to use a variety of standard userinterface widgets (@pxref{Widgets}) such as push, radio and checkbuttons, menus, lists and frames. It also provides several ``container''widgets which can be used to control the layout of the user interfaceelements.GTK provides some unique features. (At least, I know of no other widgetlibrary which provides them). For example, a button does not contain alabel, it contains a child widget, which in most instances will be alabel. However, the child widget can also be a pixmap, image or anycombination possible the programmer desires. This flexibility is adheredto throughout the library.@c I think the next paragraph takes unproportionally much space for@c the thing it wants to say (compared to the rest of this overview).@c So Somebody please extend this overview with more generally interesting@c stuff. - mvoTo make life easier for you, GTK presents this flexibility in a uniformframework.  Specifically, it implements its own support for objectoriented programming that is well adapted to the purposes of a userinterface toolkit and it aims at providing a reasonable sane anddisciplined programming interface.  This uniformity and discipline isintended to make it easy and reliable to access GTK from languages otherthan C.  Especially more dynamic languages like Perl, Python or Schemewill find amble support, and in fact, bindings to these languagesalready exist.@node Types, Objects, Overview, Top@comment node-name, next, previous, up@chapter Types@cindex type@cindex type system@cindex class@flushrightOther kid's games are all such a bore!They've gotta have rules and they gotta keep score!@*-- Calvin about CalvinBall(tm)@end flushrightGTK implements a semi-simple type system with an associated classmechanism for widgets and several other useful objects.  This typesystem is intended to be general enough to allow both a smooth bindingof dynamically typed languages to Gtk, as well as to serve for arigorous and formalistic definition of the larger part of the Gtk API.@c  The GtkObject@c  type is the root of the class hierarchy. It provides a few items needed@c  by all classes, the foundation for the signal (@pxref{Signals})@c  mechanism and the ``destroy'' method.The classes for the individual widgets are by far the most importantpart of this type system, but before we get to them, we describe thebasics of the type system itself.  This is mostly of interest for widgetwriters and language binders, so you might want to skip ahead to thenext chapter, which talks about the object oriented stuff.@menu* Type introduction::           * Basics::                      * Simple types::                * Enumerations and flags::      * Strings::                     * Boxed types::                 * Callbacks::                   * Composite types::             @end menu@node Type introduction, Basics, Types, Types@section Introduction to the Type SystemGtk defines its own system of types, much like a computer languagedefines what types it supports.  Of course, the Gtk type system is buildon top of the types that C provides, so it includes members like@samp{int}, @samp{long} and @samp{float}.  But, compared to C, it allowsonly few carefully selected types and specifies a lot of restrictions onthe way you can use values of these types.  For example, there is nogeneral facility for specifying @emph{pointer to X}.  Instead, we take amore higher level approach and define such things as @samp{string},which is just like a @code{char*} but with additional rules about how tomanage the memory that it points to.The type system has two purposes: to define a formal system with whichto describe the various exported features of Gtk; and to implement thissystem at run-time so that we get sound and flexible @dfn{dynamic} typesfor the dynamic languages that want to interface with Gtk.Let me restate this with different words, because I think it isimportant to understand this idea.  We will see in a moment that thetype system is indeed well defined and all this detail is implementedwith functions and data structures in Gtk.  For example, every type (andthere can be any number of them) can be represented with a uniqueinteger and Gtk has support for the necessary bookkeeping for this.Every type also has a name and there are functions for convertingbetween the name of a type and its unique number.  Maybe more useful,there is a big discriminated union that can be used to pass around avalue of any representable type, together with its precise type.This is the run-time or dynamic side of the type system.  Mostly, you donot need to use it when you don't want to.  The compile-time or staticside of the type system can is used to statically define the programminginterface of Gtk.  For example, suppose there is function @code{gtk_foo}in the Gtk API that has a prototype@examplechar *gtk_foo (char *);@end exampleThis looks like it does something with strings.  But what does it dowith the memory of the string that has been passed in, and what are wesupposed or allowed to do with the memory that the returned pointerpoints to?  The more restricted type @samp{string} from the Gtk typesystem can be used to be more precise.  In fact, the definition of@samp{string} below includes the rule that when a @samp{string} ispassed to a function, that function is not allowed to retain a pointerinto the string beyond the life time of that function call.  So we aresafe to deallocate it or override it when the function has returned.Likewise, the definition specifies that the memory of a @samp{string}that is returned from a function becomes the sole property of thecalling function.  The calling function is responsible for deallocatingit eventually and it can be sure that nobody else scribbles in it.  When@samp{gtk_foo} really obeys these rules, we can say that it takes oneargument, which is a @samp{string}, and it returns a @samp{string}.Now we can understand why it makes sense to have a more restrictive typesystem than that of C.  With it, it is possible to be more precise andwe actually have a framework where we can be sure that as long as westay inside this framework we are not gratuitously causing trouble forlanguages that are more disciplined than C.  Of course, you are notrestricted to making all your interfaces expressible within theframework.  There are valid reasons for breaking it, for performance orsimply for convenience.  But please try to provide all the functionalityof your module in such a way that it can be described with this typesystem and treat the non-conforming functions as additional goodies thatare nice to have but not essential.  The reward is an instantaccessibility of your code from a huge number of scripting and extensionlanguages such as Perl, Python, and Guile.These formal specifications of the Gtk interface are contained inspecial declarations in the header files of Gtk.  They are ignored bythe C compiler, but can be used by other language processors.  For extraconvenience, these declarations are also available in a more condensedform that is easier to parse.  Tools for generating bindings of Gtk toother languages can read these declarations and---because all theimportant details are defined---automatically generate the bulk of theneeded glue code.  It is also possible to feed these declarations into arunning application (a interface builder, say) and thus make it aware ofnew widgets and functions without recompiling anything.The run-time side of the type system is also somewhat introspective.This means that you can query Gtk about all the members of anenumeration for example.  Gtk provides tools that help you provide thisintrospection for your definitions also.Types are not enough to completely specify an interface, so GTK also has@dfn{modes}.  A mode specifies what happens to a value when it crosses amodule boundary; it can be @samp{in}, @samp{out}, or @samp{inout}.  Mostfundamental types (and their derived types) support only mode @samp{in}.The modes @samp{out} and @samp{inout} can only be used with thecomposite types: lists and vectors.  When argument of these types are

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -