asp.net create qr code CREATING CUSTOM WIDGETS in Font

Maker ECC200 in Font CREATING CUSTOM WIDGETS

CHAPTER 11 CREATING CUSTOM WIDGETS
Print ECC200 In None
Using Barcode drawer for Font Control to generate, create Data Matrix 2d barcode image in Font applications.
www.OnBarcode.com
European Article Number 13 Encoder In None
Using Barcode maker for Font Control to generate, create EAN-13 image in Font applications.
www.OnBarcode.com
Testing the Widget
Encoding Data Matrix ECC200 In None
Using Barcode maker for Font Control to generate, create ECC200 image in Font applications.
www.OnBarcode.com
Generate ANSI/AIM Code 39 In None
Using Barcode generation for Font Control to generate, create Code 3 of 9 image in Font applications.
www.OnBarcode.com
Now that the widget sources are written, it is time to test the widget. A small test application can be viewed in Listing 11-27. A timeout is added, which will make a call to my_marquee_slide() about every 150 milliseconds. The marquee is set with an initial message to display of Wheeeee! and will move 10 pixels to the left every time my_marquee_slide() is called. Listing 11-27. Test the MyMarquee Widget (marqueetest.c) #include <gtk/gtk.h> #include "mymarquee.h" int main (int argc, char *argv[]) { GtkWidget *window, *marquee; PangoFontDescription *fd; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "MyMarquee"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); fd = pango_font_description_from_string ("Monospace 30"); marquee = my_marquee_new (); gtk_widget_modify_font (marquee, fd); my_marquee_set_message (MY_MARQUEE (marquee), "Wheeeee!"); my_marquee_set_speed (MY_MARQUEE (marquee), 10); pango_font_description_free (fd); g_timeout_add (150, (GSourceFunc) my_marquee_slide, (gpointer) marquee); gtk_container_add (GTK_CONTAINER (window), marquee); gtk_widget_show_all (window); gtk_main (); return 0; }
Barcode Creator In None
Using Barcode generation for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
UCC - 12 Printer In None
Using Barcode maker for Font Control to generate, create GS1 - 12 image in Font applications.
www.OnBarcode.com
CHAPTER 11 CREATING CUSTOM WIDGETS
Generate UCC.EAN - 128 In None
Using Barcode creator for Font Control to generate, create UCC-128 image in Font applications.
www.OnBarcode.com
Printing MSI Plessey In None
Using Barcode creator for Font Control to generate, create MSI Plessey image in Font applications.
www.OnBarcode.com
Implementing Interfaces
Printing DataMatrix In VS .NET
Using Barcode maker for Reporting Service Control to generate, create Data Matrix image in Reporting Service applications.
www.OnBarcode.com
Encoding ECC200 In None
Using Barcode generator for Office Word Control to generate, create Data Matrix ECC200 image in Microsoft Word applications.
www.OnBarcode.com
In past chapters, you have been introduced to a number of interfaces including GtkCellEditable, GtkEditable, GtkFileChooser, GtkTreeModel, and GtkRecentChooser. Interfaces in GObject are very similar to those in Java. New interfaces are derived from GTypeInterface as shown in Listing 11-28.
ECC200 Generator In Java
Using Barcode drawer for Android Control to generate, create DataMatrix image in Android applications.
www.OnBarcode.com
Data Matrix 2d Barcode Creator In Visual C#.NET
Using Barcode maker for VS .NET Control to generate, create ECC200 image in .NET applications.
www.OnBarcode.com
Note The code in this section simply implements a very basic interface and object to illustrate what is necessary to use interfaces. For any practical purposes, it would need to be greatly expanded to include much more API.
EAN / UCC - 14 Generation In None
Using Barcode maker for Excel Control to generate, create EAN 128 image in Microsoft Excel applications.
www.OnBarcode.com
Barcode Creation In VS .NET
Using Barcode encoder for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Listing 11-28. The Interface Header File (myiface.h) #ifndef __MY_IFACE_H__ #define __MY_IFACE_H__ #include <gtk/gtk.h> G_BEGIN_DECLS (my_iface_get_type ()) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ GTK_TYPE_IFACE, MyIFace)) #define MY_IS_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ GTK_TYPE_IFACE)) #define MY_IFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \ MY_TYPE_IFACE, MyIFaceInterface)) typedef struct _MyIFace MyIFace; typedef struct _MyIFaceInterface MyIFaceInterface; struct _MyIFaceInterface { GTypeInterface parent; void (*print_message) (MyIFace *obj, gchar *message); }; GType my_iface_get_type (); void my_iface_print_message (MyIFace *obj, gchar *message); G_END_DECLS #endif /* __MY_IFACE_H__ */ #define MY_TYPE_IFACE #define MY_IFACE(obj)
Scan ECC200 In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Recognize Barcode In C#.NET
Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
CHAPTER 11 CREATING CUSTOM WIDGETS
Make Barcode In Java
Using Barcode maker for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Denso QR Bar Code Generator In Objective-C
Using Barcode generator for iPad Control to generate, create QR Code ISO/IEC18004 image in iPad applications.
www.OnBarcode.com
You will notice that the myiface.h header file contains much of the same functions and structures as when we were creating new widgets. There are four definitions; they return the interface s GType, cast the interface, check whether it is a valid GTK_TYPE_IFACE, and return the associated interface. When declaring interfaces, you must declare a type definition for the MyIFace structure, but this is merely an opaque type that allows MY_IFACE() to work. The MyIFaceInterface is the actual content of the interface. It should include a GTypeInterface object, which is the parent type of every interface. It also includes one or more function pointers. The programmer overrides these functions when an object implements the given interface. This allows each object to implement the interface in its own way, while still providing the consistency of naming across multiple objects.
QR Code ISO/IEC18004 Printer In VB.NET
Using Barcode maker for .NET Control to generate, create QR-Code image in .NET applications.
www.OnBarcode.com
Barcode Generator In Java
Using Barcode drawer for BIRT Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
Implementing the Interface
Listing 11-29 is a very basic implementation of the MyIFace source file. It provides functions for registering a new interface GType, initializing the interface class, and calling the member function. Listing 11-29. The Interface Source File (myiface.c) #include "myiface.h" static void my_iface_class_init (gpointer iface); GType my_iface_get_type () { static GType type = 0; if (!type) { type = g_type_register_static_simple (G_TYPE_INTERFACE, "MyIFace", sizeof (MyIFaceInterface), (GClassInitFunc) my_iface_class_init, 0, NULL, 0); g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET); } return type; }
CHAPTER 11 CREATING CUSTOM WIDGETS
static void my_iface_class_init (gpointer iface) { GType iface_type = G_TYPE_FROM_INTERFACE (iface); /* Install signals & properties here ... */ } void my_iface_print_message (MyIFace *obj, gchar *message) { MY_IFACE_GET_INTERFACE (obj)->print_message (obj, message); } The first function in Listing 11-29 is used to register the MyIFace type. This is done with g_type_register_static_simple(). It first accepts the GType corresponding to the parent and a name for the new type. The parent type is G_TYPE_INTERFACE for interfaces. The third parameter is the size of the interface structure, which can be obtained with the sizeof() function. GType g_type_register_static_simple (GType parent_type, const gchar *type_name, guint class_size, GClassInitFunc class_init, guint instance_size, GInstanceInitFunc instance_init, GTypeFlags flags); Next, you need to specify a class initialization function. Both the instance size and the instance initialization function can be ignored, since the instance structure is an opaque type. The last parameter is a bitwise field of GTypeFlags, which can safely be set to zero for interfaces. The other function, g_type_interface_add_prerequisite(), is used to force any object that implements the interface to also implement prerequisite_type. Interfaces can have only one prerequisite at most. void g_type_interface_add_prerequisite (GType interface_type, GType prerequisite_type); The class initialization function is similar to any other GObject class initialization function. It should be used to set up any signals and properties that are needed by the interface. Adding these to the interface means they will be available to any class that implements this interface. The last function, my_iface_print_message(), is a public function that simply calls the function located in the current MyIFaceInterface instance. This means that it will call the instance of the function that was added by the object that is implementing the interface.
Copyright © OnBarcode.com . All rights reserved.