Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Gtk+/Gnome Application Development
Prev Home Next


Once you understand drawables, colors, visuals, graphics contexts, and fonts, actually drawing is very simple. This section is a quick summary of the GDK drawing routines. Remember that drawing is a server-side operation; for example, if you ask to draw a line, Xlib will send the line's endpoints to the server, and the server will do the actual drawing using the specified GC (the GC is also a server-side resource). Often this is an important performance consideration.


You can draw a single point with gdk_draw_point(), or multiple points with gdk_draw_points() (Figure 17). The point is drawn in the current foreground color. Multiple points are given as an array. A GdkPoint looks like this:

typedef struct _GdkPoint GdkPoint;

struct _GdkPoint
  gint16 x;
  gint16 y;

Remember that X coordinates start in the top left corner, are relative to the drawable, and may not overflow a signed sixteen-bit integer.

#include <gdk/gdk.h>

void gdk_draw_point(GdkDrawable* drawable, GdkGC* gc, gint x, gint y);

void gdk_draw_points(GdkDrawable* drawable, GdkGC* gc, GdkPoint* points, gint npoints);

Figure 17. Drawing Points

Gtk+/Gnome Application Development
Prev Home Next

  Published under free license. Design by Interspire