Welcome!

PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder, .NET

PowerBuilder: Article

PowerBuilder 15 Classic Sneak Preview

MDI Docking Windows and Tabs

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:

  1. 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)
  2. Docked: In PB.NET IDE, all other windows, e.g., Toolbox, Solution Explorer, etc.
  3. Floating
  4. 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).

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:

  • OpenSheetAsDocument
  • OpenSheetDocked
  • OpenSheetInTabGroup
  • OpenSheetWithParmAsDocument
  • OpenSheetWithParmDocked
  • OpenSheetWithParmInTabGroup

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).

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).

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).

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:

Figure 5

  • 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

Figure 6

Figure 7

Conclusion
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!

More Stories By Frederick Koh

Frederick Koh is a Staff Engineer at Sybase, Inc., and has been a member of the PowerBuilder and DataWindow.NET development team since 2005. Frederick has over 14 years of IT industry experience.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.