📄 cha-gdk.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head> <title> GDK Basics </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="Advanced GTK+/Gnome Techniques" href= "advanced.html"> <link rel="PREVIOUS" title="Attaching Data to Objects" href= "sec-objectdata.html"> <link rel="NEXT" title="GdkWindow" href="sec-gdkwindow.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="sec-objectdata.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="sec-gdkwindow.html"><font color="#0000ff" size="2"><b>Next >>></b></font></a> </td> </tr> </table> </div> <div class="CHAPTER"> <h1> <a name="CHA-GDK">GDK Basics</a> </h1> <div class="TOC"> <dl> <dt> <b>Table of Contents</b> </dt> <dt> <a href="cha-gdk.html#Z112">GDK and Xlib</a> </dt> <dt> <a href="sec-gdkwindow.html"><span class="STRUCTNAME"> GdkWindow</span></a> </dt> <dt> <a href="sec-gdkvisual.html">Visuals and Colormaps</a> </dt> <dt> <a href="sec-gdkdrawable.html">Drawables and Pixmaps</a> </dt> <dt> <a href="sec-gdkevent.html">Events</a> </dt> <dt> <a href="sec-gdkcursor.html">The Mouse Pointer</a> </dt> <dt> <a href="sec-gdkfont.html">Fonts</a> </dt> <dt> <a href="sec-gc.html">Graphics Contexts</a> </dt> <dt> <a href="z132.html">Drawing</a> </dt> <dt> <a href="sec-gdkresourcemgmt.html">GDK Resource Management</a> </dt> <dt> <a href="sec-style.html"><span class="STRUCTNAME"> GtkStyle</span> and Themes</a> </dt> </dl> </div> <p> This chapter will discuss GDK, the underpinning of GTK+, and some of the occasions you might have to use it. To write custom widgets and canvas items, you will need to understand a few of these low-level details. Like chapters two and three, this chapter is a quick summary that doesn't hold your hand; there is no way to cover all of GDK in a single chapter. However, the chapter will try to cover the important concepts and data types of GDK, and should be a useful reference on certain topics. As details come up in later chapters, you can use this background to understand them. This chapter does not attempt to exhaustively catalog GDK's API. </p> <div class="SECT1"> <h1 class="SECT1"> <a name="Z112">GDK and Xlib</a> </h1> <p> The X Window System comes with a low-level and thoroughly unpleasant library called Xlib. Almost every function in GDK is a very thin wrapper around a corresponding Xlib function; but some of the complexity (and functionality) of Xlib is hidden, to simplify programming and to make GDK easier to port to other windowing systems. (There is a port of GDK to Windows available.) The concealed Xlib functionality will rarely be of interest to application programmers; for example, many features used only by window managers are not exposed in GDK. If necessary, you can use Xlib directly in your application by including the special <tt class="FILENAME">gdk/gdkx.h</tt> header file. (Check out the GDK source code to see how to extract the low-level Xlib data structures from their GDK wrappers.) </p> <p> If you need excruciating details on a GDK function, you can typically glance at the source to determine the Xlib function it wraps, and then read the man page for the Xlib function. For example, here is the implementation of <tt class="FUNCTION">gdk_draw_point()</tt>: </p> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> voidgdk_draw_point (GdkDrawable *drawable, GdkGC *gc, gint x, gint y){ GdkWindowPrivate *drawable_private; GdkGCPrivate *gc_private; g_return_if_fail (drawable != NULL); g_return_if_fail (gc != NULL); drawable_private = (GdkWindowPrivate*) drawable; if (drawable_private->destroyed) return; gc_private = (GdkGCPrivate*) gc; XDrawPoint (drawable_private->xdisplay, drawable_private->xwindow, gc_private->xgc, x, y);} </pre> </td> </tr> </table> <p> Each data structure is cast to its "private" version, which contains information relating to the particular window system GDK is being used on; this is to keep window-system-specific declarations out of the <tt class= "FILENAME">gdk/gdk.h</tt> header file. The private version of each data structure contains a wrapped Xlib data structure, which is passed to <tt class="FUNCTION"> XDrawPoint()</tt>. So the <tt class="FUNCTION"> XDrawPoint()</tt> documentation will also apply to <tt class="FUNCTION">gdk_draw_point()</tt>. </p> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="sec-objectdata.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="sec-gdkwindow.html"><font color="#0000ff" size="2"><b>Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b>Attaching Data to Objects</b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b><span class= "STRUCTNAME">GdkWindow</span></b></font> </td> </tr> </table> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -