Related Links |
Saturday, January 6. 2007Using Layout ManagersUsing Layout Managers The Concept Layout managers were created to simplify interface design and free the designer from the drudgery of calculating the coordinates for each element on the page and worrying about properties, attributes and display problems relating to any specific elements. While the concept is laudable and helpful, it was not the ultimate panacea for the web designer’s problems. While it was possible to use different layout managers for different containers on a page and these layout managers gave sizes and positions to the components in the window and are helpful for windows whose size changed or were displayed on multiple operating systems, they did not provide the ultimate sought after solution. Complex layouts with nested containers, invisible components all come packaged with their own peculiar problems and layout managers can be as frustrating to the designer as manual arrangement of elements on a web page! A basic requirement of web design is portability. Standard UI design techniques do not guarantee portability. What looks beautiful on the design platform may be distorted beyond recognition in other platforms. The first portable layout managers were designed in Java with a guarantee of being deployable on multiple platforms. These layout managers specified rules and constraints for the layout of the user interface. The advantages of these layout managers were that they correctly positioned components that were independent of fonts, screen resolutions and platform differences. They provided intelligent component placement for containers when they are dynamically resized. They also provided for ease of translation to make allowances for increase in the length of the string on translation. The Java UI container comes inbuilt with a special object called the layout manager. This component controls the components in the container. It automatically arranges the components in accordance with the rules, properties, constraints specified by the layout manager. The preferredSize, minimumSize, maximumSize, alignmentX and alignmentY and the size of the container are specified. The user can accept the default layout manager or override the settings and specify a custom layout manager. All layout managers use absolute positioning. Therefore, components do not adjust automatically when parent containers are resized. The properties of different layout containers are as under: BorderLayout has a hgap(horizontal gap) and vgap(vertical gap) to determine the distances between the components. Each component has a constraint value with possible values like North, south, east, west and center. FlowLayout and GridLayout properties can be used to align components with reference to the vertical and horizontal gaps. GridLayout also has the option of specifying the number of rows and columns. GridBagLayout has no properties. However, it has GridBagLayoutConstraints object associated with it which has properties of height and width of the component linked to it. It also has information about where the component in anchored in its cell, how the component fills up the cell, or how much padding surrounds the component inside its cell. Java uses different types of information to determine the position and size of components placed in the container. Layout managers in C# were different from the Java layout managers. While Java relegated layout managers to Graphical User Interfaces, in C# anything that implements Ilayoutable interface can be laid out. Moreover, since the layoutable objects are abstract concepts, distinct areas of the parent component can be laid out. This gives a lot of power to the web designer. Layout managers in Visual Studio 2003 are analogous to the layout managers of Java in that it implements Flow layout and Grid Layout. ASP.NET 2.0 introduced Master pages as a layout concept. Master pages implement standard visual and functional capabilities throughout the web based application and work in conjunction with content pages. Content will be populated into the placeholders for content provided in the master pages. Personalization features, takes the concept a little further by allowing users to select and populate their pages with components. Layout Examples TLB pages TLB stands for Translation look-aside buffer. This is a table in the processor’s memory and contains information about the recently created pages in the memory. The program’s virtual memory is cross-referenced with the corresponding absolute address in the physical memory. This enables faster computing. The TLB contains about 64-256 entries. The number of entries in the TLB is multiplied by the page size defined in the TLB reach. This is critical to the performance of the application and the performance begins to degrade once the TLB reaches the critical point. During the recent years the TLB is failing to keep pace with the increasingly large working sets of applications. Modern processor cache is getting large and few microprocessors have a TLB reach larger than the secondary cache for conventional page sizes. TLB misses become more common while accessing data from the cache and this increases the latency to memory. Efforts are being made to increase the TLB using the memory controller TLB. This will let the designer aggressively create super pages from non-contiguous, unaligned regions of the physical memory. Shadow pages are supported by the MTLB and this greatly empowers the Operating System’s ability to swap shadow-backed super pages more efficiently. Header and Footer Pages Sites that are several pages long would like to introduce a header and footer that will look identical on all pages. This header or footer should be capable of being changed when the designer wants to change the look and feel of the site. Header and footer pages are generally HTML pages that are part of the “includes” in PHP or master files in ASP.NET. Look at the following file created in PHP. <html> All pages associated with this header file will have to have the extension .php and then the header and footer files will have to be created. Enter all the details from the Layout that you want reflected in every page and name the file header.inc. The header file will appear as under: <html> Note that the code is truncated before the content starts. The Footer.inc file will reflect the footer layout as under: </div> Both the header.inc and the footer.inc files will have to be uploaded to the same folder as the pages in the website. Layout coding should not be part of any of the files in your folder, else your header and footer files will be overridden. At the head of every file enter the following code: <?php include("header.inc"); ?> Below the content, the following code will have to be added. <?php include("footer.inc"); ?> The include files can be named with any extension so long as the correct extension is specified in the include code. In Java too, the include files can specify the header and footer files to be included as in PHP. The classic ASP can include any type of script files as include files for headers and footers. The extension ASP or INC or HTM can be specified. The development of User controls offered greater flexibility, reliability and speed. Header user controls can be created by renaming the HTML file into head.ascx. The header must be registered and then called as under: <%@ Page Language="VB" runat="server" %> <body> ASP.NET 2.0 Master pages are used for creating consistent and maintainable interfaces and derives from the UserControl class. The PreInit event of the master page is called before the PreInit event of the content page is called and the content page fills into the content placeholder on the master page and becomes a child of the master page before it is displayed. In absolute positioning layout of components the footer pages will have to take into consideration the length of the longest column, while the header will have to take into consideration the start of the columns.. Floating Window Pages Floating windows help the designer divide the web page into rectangles that can be formatted independently of each other. They could be like DHTML layers—they can be hidden, shown or animated on top of the page. They can contain other HTML elements, such as text or image and another floating box if required. However, some web browsers do have problems with the floating windows, which have embedded floating boxes as the child-floating box inherits the CSS from the parent-floating box. A large number of designers are tending to move towards use of floating layers instead of popup windows. These are just HTML elements such as divs styled to sit on top of the rest of the page. This window usually has a close button on the top right corner for ease of dismissal. The important facts about floating windows are that popup blockers cannot block them. It forces the audience to look at the window—at least to figure out how it can be dismissed. If a link on the page is clicked the floating window will disappear with the rest of the page. Often JavaScript is used to close them but not for displaying them. They behave like normal windows on all computers. They cannot be minimized or resized. It is also not possible to switch back and forth between a floating window and the main page. Absolutely positioned floating windows have been used for creating attractive and “never scroll out of view” menus. Stretchable pagesWeb pages that stretch to fit into any window is the latest craze in web design. If the page does not stretch a lot of white space around it looks pretty bad. A simple solution is to center the design, but the white space remains a fact. Relative sizing using percentage values on tables does not allow for any arbitrary screen size. So stretching the pages to fit the window without distorting the elements composing it is a task that tests the ingenuity of the web designer. However, stretchable pages have some disadvantages. Stretching limits the page design and can cause readability problems. They should be used with caution and that too only with pages that have a great deal of content such as portal pages or company home pages. Stretchable pages must flexibly expand horizontally. This will be possible if solid color backgrounds are used or patterns that do not distort on stretching are used. Text is usually laid out in columns and more the columns the greater the ease of reading. However, if there are too few columns on a page, the text may stretch beyond a reasonable limit. Multiple column pages are easier to stretch for this reason. What has absolute positioning got to do with all the facts stated above? Absolute Positioning enables the designer design without layout managers! If the layout manager is set to null, the controls can be manually positioned using absolute positioning. However, it is not very comfortable to manually set the elements in their respective positions when the whole can be done with ease using a layout manager! Moreover, all components will get locked in place and will not adjust to the position and size if the window is resized. It is possible to take care of this issue also, but would require a lot of programming effort from your side. Trackbacks
Trackback specific URI for this entry
No Trackbacks
|
QuicksearchChaptersSyndicate This BlogContact AuthorBlog Administration |