tailieunhanh - Apress Pro PHP-GTK phần 4

Nó thường có thể để đạt được bố trí mong muốn của một ứng dụng bằng cách sử dụng hộp lồng nhau, nhưng thiết lập ứng dụng và lưu giữ những thứ có tổ chức được nhiều hơn và khó khăn hơn là mức độ làm tổ được sâu hơn. Như với hầu hết mọi thứ trong cuộc sống, có nhiều hơn một cách để đạt được kết quả tương tự. | 98 CHAPTER 6 LAYING OUT APPLICATIONS Figure 6-6. The different layouts of button boxes Tables It is often possible to achieve the desired layout of an application using nested boxes but setting up the application and keeping things organized gets more and more difficult as the levels of nesting get deeper. As with most things in life there is more than one way to reach the same result. GtkTable is a container class designed specifically for laying out an application unlike its HTML counterpart which is designed for organizing data. A GtkTable can be used to more easily display widgets in rows and columns. A GtkTable container is similar to a table in HTML. It has rows and columns made up of individual cells and each cell can span more than one row and or column. While the contents of each cell are independent the dimensions of a row or column are determined by the largest cell in that row or column. Listing 6-3 is an implementation of the _populate method from the earlier listings but it uses a GtkTable instead of nested boxes. At first glance the new version appears to be quite complicated because of all of the integers floating around but once these numbers are explained the picture clears up rather quickly. CHAPTER 6 LAYING OUT APPLICATIONS 99 Listing 6-3. Laying Out an Application Using GtkTable php . private function _populate Create a new table with 5 rows and 3 columns. table new GtkTable 5 3 Make it easier to set both expand and fill at the same time. expandFill Gtk EXPAND Gtk FILL Attach two frames to the table. table- attach new GtkFrame MENU 0 2 0 1 expandFill 0 0 0 table- attach new GtkFrame TOOLBAR 0 2 1 2 expandFill 0 0 0 Create a new frame and set its size. productTree new GtkFrame PRODUCT TREE productTree- set_size_request 150 -1 Attach the frame to the table. table- attach productTree 0 1 2 3 0 expandFill 0 0 Create a new frame and set its size. news new GtkFrame NEWS news- set_size_request 150 -1 Attach the frame to the table. table- attach news 0

TỪ KHÓA LIÊN QUAN