📄 gtk.html
字号:
<DL><DT><U>Macro:</U> GtkFundamentalType <B>GTK_FUNDAMENTAL_TYPE</B> <I>(GtkType type)</I><DD><A NAME="IDX12"></A>Returns the fundamental type of <VAR>type</VAR>.</DL></P><P>Both macros simply access different bit-fields of a <CODE>GtkType</CODE>, sothey are very efficient.</DL></P><P>New types are registered with the <CODE>gtk_type_unique</CODE> function. Anykind oftype can be registered with <CODE>gtk_type_unique</CODE> but there areconvenience functions for most fundamental types. Each fundamental typehas its own interpretation of the rules below and these conveniencefunctions should be used to automatically get the type registrationright. So, don't be put off by the apparent complexity of the interfaceto <CODE>gtk_type_unique</CODE>. You will be using it only for new widgets,and there the rules are simple.</P><P>The <CODE>GtkTypeInfo</CODE> structure is used to communicate information to<CODE>gtk_type_unique</CODE> as opposed to passing in large numbers ofparameters.</P><PRE>typedef struct _GtkTypeInfo GtkTypeInfo;struct _GtkTypeInfo{ gchar *type_name; guint object_size; guint class_size; GtkClassInitFunc class_init_func; GtkObjectInitFunc object_init_func; gpointer reserved_1; gpointer reserved_2; GtkClassInitFunc base_class_init_func;}</PRE><UL><LI>The <CODE>type_name</CODE> field refers to the name of the type. This is thesame name that is used in the static definitions. It is convention forthe type name to be closely related to the name of the underlying Ctype. For example, the type name of the <CODE>GtkObject</CODE> structure is"GtkObject", and the name of the <CODE>GtkWindowType</CODE> enumeration is"GtkWindowType". Note that the C type corresponding to "GtkObject"is really a pointer to a <CODE>GtkObject</CODE> struct, but the name has no"*" in it.<LI>The <CODE>object_size</CODE> field refers to the size in bytes of the Cstructure for types that have such a structure. The easiest (andportable) means of computing this size is by using the C <CODE>sizeof</CODE>operator. For instance, the sizeof of the <CODE>GtkObject</CODE> structure iscomputed by doing <CODE>sizeof (GtkObject)</CODE>. When the type has noassociated structure or when you do not want to support the<CODE>gtk_type_new</CODE> function for the new type, set <CODE>object_size</CODE> to0. Only types derived from GTK_TYPE_OBJECT can be handled by<CODE>gtk_type_new</CODE>, anyway.<LI>The <CODE>class_size</CODE> field refers to the size in bytes of the Cstructure for the class. Again, the <CODE>sizeof</CODE> operator should beused to compute this value. If you don't want to have a class structurefor this type, set the field to 0. <CODE>gtk_type_class</CODE> will thenalways return <CODE>NULL</CODE>.<LI>The <CODE>class_init_func</CODE> and <CODE>base_class_init_func</CODE> fields arecallbacks which are used by the type mechanism to initialize classspecific fields. The single argument these function taks is a pointer toa class structure. When you do not need one or both of them, set thecorresponding field to <CODE>NULL</CODE>. The <CODE>class_init_func</CODE> will becalled at most once, right after the class structure of size<CODE>class_size</CODE> has been allocated. The interaction between<CODE>class_init_func</CODE> and <CODE>base_class_init_func</CODE> is only reallyuseful for the full-fledged object system. It is described theresee section <A HREF="gtk.html#SEC12">Objects</A>.<LI>The <CODE>object_init_func</CODE> field is a callback which is used by thetype mechanism to initialize object specific fields for structures thathave been allocated via <CODE>gtk_type_new</CODE>. The single argument thisfunctions takes is a pointer to an object structure. If you do not wantany special object initialization to take place, set this to<CODE>NULL</CODE>. All object initialization functions for all types that arepart of the inheritance chain are called, starting with the most basictype.</UL><P><DL><DT><U>Function:</U> guint <B>gtk_type_unique</B> <I>(GtkType <VAR>parent_type</VAR>, GtkTypeInfo *<VAR>type_info</VAR>)</I><DD><A NAME="IDX13"></A>The <VAR>parent_type</VAR> is simply the new types parent type. If<VAR>parent_type</VAR> is GTK_TYPE_INVALID, then the new type is a newfundamental type. You should <B>never</B> register new fundamental types.<VAR>type_info</VAR> is a pointer to a structure which contains necessaryinformation for construction of the new type.</P><P>You can only register a specific name once.</DL></P><P><DL><DT><U>Function:</U> gchar* <B>gtk_type_name</B> <I>(GtkType <VAR>type</VAR>)</I><DD><A NAME="IDX14"></A>The returned string is the name of <VAR>type</VAR> as specified to<CODE>gtk_type_unique</CODE>.</DL></P><P><DL><DT><U>Function:</U> GtkType <B>gtk_type_from_name</B> <I>(guchar *<VAR>name</VAR>)</I><DD><A NAME="IDX15"></A>Return the type associated with <VAR>name</VAR>. If there is no typeassociated with <VAR>name</VAR>, then GTK_TYPE_INVALID will be returned.</DL></P><P><DL><DT><U>Function:</U> GtkType <B>gtk_type_parent</B> <I>(GtkType <VAR>type</VAR>)</I><DD><A NAME="IDX16"></A>Returns the parent type of <VAR>type</VAR> or GTK_TYPE_INVALID if <VAR>type</VAR>is a fundamental type.</DL></P><P><DL><DT><U>Function:</U> gpointer <B>gtk_type_class</B> <I>(GtkType <VAR>type</VAR>)</I><DD><A NAME="IDX17"></A>Returns the initialized class structure for <VAR>type</VAR>. The classstructure is actually created and initialized the first time it isneeded. Refer to see section <A HREF="gtk.html#SEC12">Objects</A> for details on how this initialization works for GTK_TYPE_OBJECT derived types.</P><P>The returned structure is shared by all objects of <VAR>type</VAR> and, assuch, should not be modified.</DL></P><P><DL><DT><U>Function:</U> gpointer <B>gtk_type_new</B> <I>(GtkType <VAR>type</VAR>)</I><DD><A NAME="IDX18"></A>Returns a new instance of an <VAR>type</VAR> object. This works only for GTK_TYPE_OBJECT derived types. Please see see section <A HREF="gtk.html#SEC12">Objects</A>.</DL></P><P><DL><DT><U>Function:</U> void <B>gtk_type_describe_heritage</B> <I>(GtkType <VAR>type</VAR>)</I><DD><A NAME="IDX19"></A>Prints the type heritage for <VAR>type</VAR>. The heritage for a typeincludes the type and all its parent types up the type tree.</DL></P><P><DL><DT><U>Function:</U> void <B>gtk_type_describe_tree</B> <I>(GtkType <VAR>type</VAR>, gboolean <VAR>show_size</VAR>)</I><DD><A NAME="IDX20"></A>Prints the type tree which starts at <VAR>type</VAR>. <VAR>show_size</VAR> is aboolean which determines whether type sizes are printed.</DL></P><P><DL><DT><U>Function:</U> gboolean <B>gtk_type_is_a</B> <I>(GtkType <VAR>type</VAR>, GtkType <VAR>is_a_type</VAR>)</I><DD><A NAME="IDX21"></A>A predicate function which determines whether the relation <VAR>type</VAR>is_a <VAR>is_a_type</VAR> is true.</DL></P><P>Values of all types can be handled uniformly by storing them into a<CODE>GtkArg</CODE> structure. The <CODE>GtkArg</CODE> has the following fields:</P><DL COMPACT><DT><CODE>gchar *name</CODE><DD>This can be used to give the value represented by this <CODE>GtkArg</CODE>structure a name. It is not used much.<DT><CODE>GtkType type</CODE><DD>The type of this value.<DT><CODE>union d</CODE><DD>A big union that has (at least conceptually) one member for eachfundamental type. You should not access these members directly.Rather, use the <CODE>GTK_VALUE_*</CODE> macros. There is one macro for eachfundamental type, and its name is derived from the name of theGtkFundamentalType enumeration members simply by replacing "Gtk_TYPE"with "GTK_VALUE". All <CODE>GTK_VALUE_*</CODE> macros take a <CODE>GtkArg</CODE>structure as their only parameter (<EM>not</EM> a pointer) and evaluate toa lvalue.</DL><P>For example, the accessor for the fundamental type GTK_TYPE_INT iscalled GTK_VALUE_INT and you could use it like this:</P><PRE>GtkArg value;value.name = NULL;value.type = GTK_TYPE_INT;GTK_VALUE_INT(value) = 7;</PRE><H2><A NAME="SEC6" HREF="gtk_toc.html#TOC6">Simple Types</A></H2><P>The Gtk type system has a full set of the usual simple types: integers,floating point numbers, but also boolean and character. You can notderive new types from these.</P><TABLE><TR>Enum <TD> Name <TD> Description<BR><TR>GTK_TYPE_NONE <TD> "void"<TD> A type without value.<BR><TR>GTK_TYPE_CHAR <TD> "char"<TD> A 8-bit unsigned number representing a character. Numbers between 0 and 127 are ASCII, the rest is undefined.<BR><TR>GTK_TYPE_BOOL <TD> "gboolean"<TD> The boolean type. It is some small integer where the number 0 represents false and 1 is true. No other values are allowed.<BR><TR>GTK_TYPE_INT <TD> "gint"<TD> A signed integer with at least 32 bits.<BR><TR>GTK_TYPE_UINT <TD> "guint"<TD> A unsigned integer with at least 32 bits.<BR><TR>GTK_TYPE_LONG <TD> "glong"<TD> A signed integer with at least 32 bits.<BR><TR>GTK_TYPE_ULONG <TD> "gulong"<TD> A unsigned integer with at least 32 bits. This is large enough to hold a coerced pointer.<BR><TR>GTK_TYPE_FLOAT <TD> "gfloat"<TD> A single precision floating point number.<BR><TR>GTK_TYPE_DOUBLE <TD> "gfloat"<TD> A souble precision floating point number.<BR><TR>GTK_TYPE_POINTER <TD> "gpointer"<TD> A untyped pointer. Do not use this if you can avoid it.</TABLE>The values of these types are all represented `directly' with the Ctypes that are indicated in the `name' column above. see section <A HREF="gtk.html#SEC9">Boxed Types</A> for a discussion of this.<H2><A NAME="SEC7" HREF="gtk_toc.html#TOC7">Enumerations and Flags</A></H2><H2><A NAME="SEC8" HREF="gtk_toc.html#TOC8">Strings</A></H2><H2><A NAME="SEC9" HREF="gtk_toc.html#TOC9">Boxed Types</A></H2><H2><A NAME="SEC10" HREF="gtk_toc.html#TOC10">Callbacks</A></H2><H2><A NAME="SEC11" HREF="gtk_toc.html#TOC11">Composite Types</A></H2><H1><A NAME="SEC12" HREF="gtk_toc.html#TOC12">Objects</A></H1><H2><A NAME="SEC13" HREF="gtk_toc.html#TOC13">Object functions</A></H2><P>The GtkObject type is the root of the type hierarchy used by GTK. Itprovides a minimal set of fields used to implement the actual object,class and signal mechanisms, as well as several utility routines whichmake dealing with objects easier.</P><P>For the adventurous, see section <A HREF="gtk.html#SEC414">Object internals</A>.</P><P><DL><DT><U>Function:</U> guint <B>gtk_object_get_type</B> <I>(void)</I><DD><A NAME="IDX22"></A>Returns the <CODE>GtkObject</CODE> type identifier.</DL></P><P><DL><DT><U>Function:</U> void <B>gtk_object_class_add_signals</B> <I>(GtkObjectClass *<VAR>class</VAR>, gint *<VAR>signals</VAR>, gint <VAR>nsignals</VAR>)</I><DD><A NAME="IDX23"></A>Adds <VAR>signals</VAR> to the <CODE>signals</CODE> field in the GtkObjectClassstructure <VAR>class</VAR>. See section <A HREF="gtk.html#SEC14">Signals Overview</A>.</DL></P><P><DL><DT><U>Function:</U> GtkObject* <B>gtk_object_new</B> <I>(guint <VAR>type</VAR>, ...)</I><DD><A NAME="IDX24"></A></DL></P><P><DL><DT><U>Function:</U> GtkObject* <B>gtk_object_newv</B> <I>(guint <VAR>type</VAR>, guint <VAR>nargs</VAR>, GtkArg *<VAR>args</VAR>)</I><DD><A NAME="IDX25"></A></DL></P><P><DL><DT><U>Function:</U> void <B>gtk_object_ref</B> <I>(GtkObject *<VAR>object</VAR>);</I><DD><A NAME="IDX26"></A></DL></P><P><DL><DT><U>Function:</U> void <B>gtk_object_unref</B> <I>(GtkObject *<VAR>object</VAR>);</I>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -