📄 gtk_tut-1.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>GTK v1.2 Tutorial: Introduction</TITLE> <LINK HREF="gtk_tut-2.html" REL=next> <LINK HREF="gtk_tut.html#toc1" REL=contents></HEAD><BODY BGCOLOR="#FFFFFF"><A HREF="gtk_tut-2.html">Next</A>Previous<A HREF="gtk_tut.html#toc1">Contents</A><HR NOSHADE><H2><A NAME="s1">1. Introduction</A></H2><P>GTK (GIMP Toolkit) is a library for creating graphical userinterfaces. It is licensed using the LGPL license, so you can developopen software, free software, or even commercial non-free softwareusing GTK without having to spend anything for licenses or royalties.<P>It's called the GIMP toolkit because it was originally written fordeveloping the General Image Manipulation Program (GIMP), but GTK hasnow been used in a large number of software projects, including theGNU Network Object Model Environment (GNOME) project. GTK is built ontop of GDK (GIMP Drawing Kit) which is basically a wrapper around thelow-level functions for accessing the underlying windowing functions(Xlib in the case of X windows). The primary authors of GTK are:<P><UL><LI> Peter Mattis <CODE><A HREF="mailto:petm@xcf.berkeley.edu">petm@xcf.berkeley.edu</A></CODE></LI><LI> Spencer Kimball <CODE><A HREF="mailto:spencer@xcf.berkeley.edu">spencer@xcf.berkeley.edu</A></CODE></LI><LI> Josh MacDonald <CODE><A HREF="mailto:jmacd@xcf.berkeley.edu">jmacd@xcf.berkeley.edu</A></CODE></LI></UL><P>GTK is essentially an object oriented application programmersinterface (API). Although written completely in C, it is implementedusing the idea of classes and callback functions (pointers tofunctions).<P>There is also a third component called glib which contains a fewreplacements for some standard calls, as well as some additionalfunctions for handling linked lists etc. The replacement functions areused to increase GTK's portability, as some of the functionsimplemented here are not available or are nonstandard on other unixessuch as g_strerror(). Some also contain enhancements to the libcversions, such as g_malloc that has enhanced debugging utilities.<P>This tutorial describes the C interface to GTK. There are GTKbindings for many other languages including C++, Guile, Perl, Python,TOM, Ada95, Objective C, Free Pascal, and Eiffel. If you intend touse another language's bindings to GTK, look at that binding'sdocumentation first. In some cases that documentation may describesome important conventions (which you should know first) and thenrefer you back to this tutorial. There are also some cross-platformAPIs (such as wxWindows and V) which use GTK as one of their targetplatforms; again, consult their documentation first.<P>If you're developing your GTK application in C++, a few extra notesare in order. There's a C++ binding to GTK called GTK--, whichprovides a more C++-like interface to GTK; you should probably lookinto this instead. If you don't like that approach for whateverreason, there are two alternatives for using GTK. First, you can useonly the C subset of C++ when interfacing with GTK and then use the Cinterface as described in this tutorial. Second, you can use GTK andC++ together by declaring all callbacks as static functions in C++classes, and again calling GTK using its C interface. If you choosethis last approach, you can include as the callback's data value apointer to the object to be manipulated (the so-called "this" value).Selecting between these options is simply a matter of preference,since in all three approaches you get C++ and GTK. None of theseapproaches requires the use of a specialized preprocessor, so nomatter what you choose you can use standard C++ with GTK.<P>This tutorial is an attempt to document as much as possible of GTK,but it is by no means complete. This tutorial assumes a goodunderstanding of C, and how to create C programs. It would be a greatbenefit for the reader to have previous X programming experience, butit shouldn't be necessary. If you are learning GTK as your firstwidget set, please comment on how you found this tutorial, and whatyou had trouble with. Note that there is also a C++ API for GTK(GTK--) in the works, so if you prefer to use C++, you should lookinto this instead. There are also Objective C, ADA, Guile and otherlanguage bindings available, but I don't follow these.<P>This document is a 'work in progress'. Please look for updates onhttp://www.gtk.org/ <A HREF="http://www.gtk.org/">http://www.gtk.org/</A>.<P>I would very much like to hear of any problems you have learning GTKfrom this document, and would appreciate input as to how it may beimproved. Please see the section on <A HREF="gtk_tut-25.html#sec_Contributing">Contributing</A> for further information.<P><HR NOSHADE><A HREF="gtk_tut-2.html">Next</A>Previous<A HREF="gtk_tut.html#toc1">Contents</A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -