TAILIEUCHUNG - Apress Pro PHP-GTK phần 8

Trong ví dụ trước, bạn đã thấy làm thế nào để tạo ra hình ảnh cho các nút và các mục menu bằng cách sử dụng ID cổ phiếu. ID chứng khoán là một phím tắt để xác định một hình ảnh thường được sử dụng. Bạn cũng có thể tạo ra một hình ảnh thường xuyên từ một ID chứng khoán bằng cách sử dụng new_from_stock. Constructor tĩnh này có ID chứng khoán cộng với một kích thước. | 258 CHAPTER 12 ADDING IMAGES Figure 12-1. A broken image icon Using a Stock ID In previous examples you have seen how to create images for buttons and menu items by using stock IDs. A stock ID is a shortcut that identifies a commonly used image. You can also create a regular image from a stock ID by using new_from_stock. This static constructor takes the stock ID plus a size. The size is defined by a GtkIconSize constant. Stock images come in different sizes so that they can be used for different purposes. Each use has its own size constant as follows Gtk ICON_SIZE_MENU A small image normally used in menus. Gtk ICON_SIZE_SMALL_TOOLBAR A small version of the icon used for toolbars. Gtk ICON_SIZE_LARGE_TOOLBAR Alarger version of the toolbar icon. Gtk ICON_SIZE_BUTTON The version normally used for buttons. Gtk ICON_SIZE_DND The icon size used when an item is dragged. Gtk ICON_SIZE_DIALOG The version normally used in dialog windows. Using a Pixel Buffer Another way to create an image is from data in memory. An image stored in memory can usually be found in a GdkPixbuf. A pixel buffer or pixbuf is simply a representation of the image in memory. It cannot be displayed on its own it is just data. You can put an image into a pixbuf when an application is started to allow commonly used images to be loaded more quickly. A pixbuf can be created from a file just as an image can be created. To create a pixbuf from a file call the static constructor new_from_file and pass a file path. Listing 12-1 creates a pixbuf from a file and then creates an image from the pixbuf using the static constructor new_from_pixbuf. Listing 12-1. Loading an Image into a GdkPixbuf and Then a GtkImage php Create a window to display the image. window new GtkWindow Close the application cleanly. window- connect_simple destroy array Gtk main_quit Load a pixbuf from a file. pb GdkPixbuf new_from_file Crisscott images CHAPTER 12 ADDING IMAGES 259 Create the image from the pixbuf. image GtkImage .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.