TAILIEUCHUNG - Apress Pro PHP-GTK phần 9

Ví dụ 14-8 cho thấy một phương pháp gọi lại có thể được kết nối với tín hiệu font-thiết lập một nút chữ để thay đổi phông chữ của một vùng lựa chọn của văn bản trong một GtkTextBuffer. Thiết lập font-tín hiệu tự động thông qua nút chữ để gọi lại. Các phông chữ được lựa chọn có thể được trả lại bằng cách sử dụng get_font_name. Phương pháp này trả về gia đình font chữ, phong cách, và kích thước là một trong chuỗi. | CHAPTER 14 USING SELECTORS DIALOGS 295 Listing 14-8 shows a callback method that could be connected to a font button s font-set signal to change the font of a selected region of text in a GtkTextBuffer. The font-set signal automatically passes the font button to the callback. The selected font can be returned using get_font_name. This method returns the font family style and size as one string. The value of get_font_name is then used to set the font property of a GtkTextTag object. This tag is then applied across the selection to modify the font of the text. Listing 14-8. A Callback for a GtkFontButton s Font-Set Signal php function applyTag fontButton text Create a new tag to modify the text. tag new GtkTextTag Set the tag font. tag- set_property font fontButton- get_font Get the buffer. buffer text- get_buffer Get iters for the start and end of the selection. selectionStart buffer- get_start_iter selectionEnd buffer- get_start_iter Get the iters at the start and end of the selection. buffer- get_iter_at_mark selectionStart buffer- get_insert buffer- get_iter_at_mark selectionEnd buffer- get_selection_bound Add the tag to the buffer s tag table. buffer- get_tag_table - add tag Apply the tag. buffer- apply_tag tag selectionStart selectionEnd By default a font button displays the font family and size of the currently selected font. The display properties of the button can be controlled. The style bold italic etc. can be added to the button s label by passing true to set_show_style. Passing false to this method will turn the style off again. Passing false to set_show_size will hide the size in the button s label. The size can be shown again by passing true to the same method. In addition to showing the font description you can control the font of the button s label. A button can be told to use the currently selected font style or size in its label. In Figure 14-7 the GtkFontButton is told to use the font and style that has been selected. This is done using the .

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.