Analysis of a component @ GTK + 2.0 Chinese tutorial serialization

Source: Internet
Author: User
Tags gtk
Analysis of a component

To create a new component, you must first understand the working principle of the GTK object. This section is just a brief description. For more information, see the reference manual.

The GTK component has the object-oriented feature. However, it is implemented using standard C. This greatly improves the portability and Stability of the current C ++ compiler. However, this also means that the write component must pay attention to some implementation details. The common information of all instances of a component class (such as all button components) is stored inClass Structure
Class signal information is only stored in this structure (as a virtual function in C ). To support inheritance, the first domain of the class structure must be a copy of its parent class structure. The class structure declaration of the gtkbutton is as follows:

struct _GtkButtonClass
{
GtkContainerClass parent_class;

void (* pressed) (GtkButton *button);
void (* released) (GtkButton *button);
void (* clicked) (GtkButton *button);
void (* enter) (GtkButton *button);
void (* leave) (GtkButton *button);
};

When a button is treated as a container (for example, when it is adjusted to an hour), its class structure is converted to gtkcontainerclass, and the corresponding fields are used to process signals.

Each component also has a structure, which is the basis for creating each instance. This structure stores different information domains for instances of each component. We call this structureObject Structure
. The following is a button class:

struct _GtkButton
{
GtkContainer container;

GtkWidget *child;

guint in_button : 1;
guint button_down : 1;
};

Note that it has similar structures. The first field is the object structure of the parent class. Therefore, this structure can be converted to the object structure of the parent class as needed.

<Previous Home Next >>>
Compile Your Own Components Up Create a composite component

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.