Objective Toolkit : Chapter 23 Layout Manager Framework : Benefits of the Objective Toolkit Layout Manager
Benefits of the Objective Toolkit Layout Manager
The concept of a layout manager is not a new idea. Java, Motif, OWL, and Visual Basic OCX’s all offer layout management. What makes the Objective Toolkit Layout Manager different is that it is tightly integration with MFC, is based on a strong and highly extensible architecture, and is easy to integrate.
Objective Toolkit Layout Manager: MFC Integration
MFC does not include default layout management. Although the Visual Studio IDE offers an excellent mechanism for creating and initializing dialog templates, it only provides a static view of your application.
The Objective Toolkit Layout Manager is written in MFC for MFC. You can plug it into your existing MFC application seamlessly, without making any modifications to your existing window class hierarchy.
In addition, the Objective Toolkit Layout Manager offers several calculation and redraw optimizations that minimize the amount of CPU processing and screen flicker that occur with every window resize.
Objective Toolkit Layout Manager: Strong Architecture
The Objective Toolkit Layout Manager is extensible by design. Most of the other layout managers offer a canned layout algorithm that is tightly tied to a specific dialog or formview implementation. In contrast, the Objective Toolkit Layout Manager is designed to be scalable. It includes a tree-like division of labor that makes it easy to nest layouts or to add your own layout type.
In addition, the Layout Manager is not tied directly to CWnd so you can position non-CWnd entities, like a rendered image, on a CView. The strong architecture detaches the layout logic from the actual visual implementation, which provides a strong component for reuse in an endless variety of contexts.
Objective Toolkit Layout Manager: Ease of Integration
Many layout managers force you to abandon your existing window base class and use a canned base class that is layout-aware. This is problematic if you are already using a custom base class (for example, a special CDialog derivative) that contains the functionality you need. Because MFC is not designed for multiple inheritance, you need to decide which of the two base classes is more valuable to you and discard the functionality of the other class.
The Objective Toolkit Layout Manager uses aggregation rather than inheritance to apply its layout logic. Merging the Layout Manager into your application is as easy as instantiating a member layout factory, and producing a listener object that hooks laterally into your existing class without making any changes to your base class. The layout factory tracks memory management and allows you to merge a layout into your existing window with as little as three lines of source code and one declared member variable.