|By Frederick Koh||
|May 4, 2012 11:00 AM EDT||
In my previous article for PowerBuilder Developer's Journal (Vol. 18 issue 8), I gave a sneak preview of some of the things we were working on for PB15 Classic. This is a closer look at one of them - Tabs and Docking in MDI Windows.
Recall that in the article we mentioned adding two new WindowType values - mdidock! and mdidockhelp! - to the window object. Like values mdi! and mdihelp!, respectively, they allow child windows (sheets) to be opened with the OpenSheet functions. But these sheets will behave differently: they can dock, float and be tabbed like the windows you see in our PB.NET IDE.
Your sheets will open docked by default (we will see how to control this later in the article). Once opened, they can be moved, docked in much the same way you can with the PB.NET IDE window. The sheets can be in one of four states:
- Tabbed Document: In PB.NET IDE, script editors and window painters are tabbed documents - anything with an entry in the "Window" menu item of the PB.NET IDE (see Figure 1)
- Docked: In PB.NET IDE, all other windows, e.g., Toolbox, Solution Explorer, etc.
- Tabbed Windows: Docked windows occupying the same space will be tabbed. The tabs appear at the bottom. Notice that in the PB.NET IDE, the Solution Explorer and Properties Window are usually docked at the same location and appear as windows in a tabbed group. The main differences with tabbed documents are that tabbed windows have tabs at the bottom and have no corresponding entries in the "Windows" menu item.
As in the PB.NET IDE, the opened sheets can be moved, docked, tabbed, and turned into tabbed documents interactively with the mouse. A property will be introduced on child windows to control which states to allow on that window. For example, you may want to prevent the end user from turning a docked window into a document (see Figure 1).
Programmatically Opening Sheets in a Specific State
To open a sheet at a specific docking location, in a specific tab group or as a document, we are introducing new versions of the OpenSheet function:
OpenSheetInTabGroup and OpenSheetWithParmInTabGroup, as their names suggest, open a sheet in a tab group. Unlike the other OpenSheet functions, these take as one of their arguments, not the parent window, but a sibling sheet. These sibling sheets must either be docked or in a tab group.
Persisting MDI State
One of the things you'll notice about the PB.NET IDE is that when you launch it, it restores all the open windows at exactly the same position and state as when you closed it. In PB15 there is going to be an easy way to get the same thing.
The most important thing is to be able to associate a meaningful string ID to each opened sheet. One suggestion - if you use the OpenSheetWithParm family of functions - is to come up with a string representation of the "parm" and be able to convert one from the other. These IDs will be needed either as arguments to the new OpenSheet functions or passed separately using the new SetSheetID function (see Figure 2).
The MDI state is stored in the registry using the new SaveDockingState function that you'll want to call when your application is closed (see Figure 3).
When your application is launched, three new functions will help you restore your sheets.
LoadDockingState will fill two equal-sized arrays. One will be an array of type names of persisted sheets. The other will be their corresponding IDs. For these persisted sheets, a new function is introduced to open them: OpenSheetFromDockingState (and OpenSheetWithParmFromDockingState). When all persisted sheets are open, the CommitDocking function will do the work of arranging everything in place and making them visible (see Figure 4).
Look and Feel
To give you more control over the look and feel of your final application, there will be new properties (see Figures 5-7) to allow you to specify:
- The colors of active and inactive title bars (horizontal/vertical gradients optional)
- The colors of the area behind tabs (horizontal/vertical gradients optional)
- The colors of tabs (active/inactive/mouseover); deferring to theme colors is also an option
- The shape of tabs
- The location of the close button for tabs
- Whether to show all tabs (squeezed) or scroll them
The most important thing to remember here is that you can start with an existing MDI application and just change the window type of your main application window. Then start experimenting with the other features - knowing (and comforted by the fact) that the controls within your MDI sheets will continue to behave correctly unchanged. Start planning for the beta!
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- Creation and Consumption of Web Services with PowerBuilder
- Cloud People: A Who's Who of Cloud Computing
- DDDW Tips and Tricks
- Cloud Expo 2011 East To Attract 10,000 Delegates and 200 Exhibitors
- Working with SOA & Web Services in PowerBuilder
- Dynamically Creating DataWindow Objects
- OLE - Extending the Capabilities of PowerBuilder
- Cloud Expo and The End of Tech Recession