• No results found

Using the u_tab Tab control and the u_tabpg user object

In document pfcug (Page 175-179)

Many current applications use Tab controls and tab pages to enhance their user interface. The u_tab Tab control and the u_tabpg user object provide basic PFC functionality. And they both implement the resize service, which you enable differently depending on how the tab is defined.

About Tab controls and tab pages

Tab control A Tab control is a control that you place in a window or user object that contains tab pages. Part of the area in the Tab control is for the tabs associated with the tab pages. Any space left is occupied by the tab pages themselves.

PFC provides the u_tab Tab control, which you can use as an ancestor for Tab controls.

Tab page A tab page contains other controls and is one of several pages within a Tab control. All tab pages in a Tab control occupy the same area of the control, and only one is visible at a time. The active tab page covers the other tab pages. There are different ways to approach tab page definition. You can define:

An embedded tab page In the Window or User Object painter, Select Insert>TabPage from the Tab control’s pop-up menu and add controls to those pages. An embedded tab page is of class UserObject but is not reusable.

A tab page user object In the User Object painter, create a custom visual user object and add the controls that will display on the tab page. To add a tab page user object to a Tab control, Select Insert>User Object from the Tab control’s pop-up menu. A tab page defined as an independent user object is reusable.

PFC provides the u_tabpg custom visual user object, which you can use as the ancestor for tab pages.

You can mix and match the two methods—one Tab control can contain both embedded tab pages and tab page user objects. But non-PFC tab pages do not

Using standard visual user objects

For more information on programming with Tab controls and tab pages, see Application Techniques.

Using u_tab When using u_tab, you always: • Work with a descendant of u_tab

• Create the complete Tab control (including tab pages) in the User Object painter

v To create a Tab control:

1 Create a user object based on u_tab.

2 Add embedded tab pages and tab page user objects. For embedded tab pages, you add controls as necessary. Tab page user objects must be completely defined; you cannot add or modify controls from within the Tab control.

3 Create, override, and extend tab-page events and functions as necessary. 4 Create, override, and extend tab-level events and functions as necessary.

Then call events in the tab pages, optionally defining user events on the Tab control that call the tab page events.

5 Add the user object to a window.

Using u_tabpg When using u_tabpg, you always work with a descendant of u_tabpg within the User Object painter.

v To create a tab page:

1 Create a user object based on u_tabpg. 2 Add controls as necessary.

3 Add PowerScript code for the controls as necessary.

4 Create, override, and extend tab page events and functions as necessary. 5 Add the tab page user object to one of the following:

• U_tab-based user object

• Standard visual user object of type Tab • Tab control within the Window painter

Using the resize service with u_tab descendants

You can use the resize service to add dynamic resize capabilities to tab pages. How you enable the resize service differs depending on whether the Tab control contains embedded tab pages or tab page user objects based on u_tabpg. If a Tab control contains both embedded tab pages and tab page user objects, you can combine the first two procedures that follow.

When using the Create on Demand option for tab page user objects, you must also perform the third procedure to ensure that controls display properly.

v To enable the resize service for a Tab control when using embedded tab pages:

1 Use the User Object painter to create a Tab control based on u_tab. 2 Define embedded tab pages.

3 Enable the resize service for the Tab control (this example is from the Constructor event):

this.of_SetResize(TRUE)

4 Register controls within the tab pages:

this.inv_resize.of_Register & (this.tabpage_1.mle_1, & this.inv_resize.SCALETOBOTTOM) this.inv_resize.of_Register & (this.tabpage_2.dw_1, & this.inv_resize.SCALETOBOTTOM)

5 Add the user object to a window.

6 Enable the resize service for the window and register affected controls (this example is from the window’s Constructor event):

this.of_SetResize(TRUE) this.inv_resize.of_Register(tab_1, "Scale") this.inv_resize.of_Register & (cb_cancel, & this.inv_resize.FIXEDTOBOTTOM) this.inv_resize.of_Register & (cb_ok, this.inv_resize.FIXEDTOBOTTOM) this.inv_resize.of_SetMinSize & (this.width - 100, this.height - 100)

Using standard visual user objects

v To enable the resize service for a Tab control when using tab page user objects based on u_tabpg:

1 Use the User Object painter to create a tab page based on u_tabpg. 2 Enable the resize service for the tab page (this example is from the

Constructor event):

this.of_SetResize(TRUE)

3 Register controls within the tab page:

this.inv_resize.of_Register & (this.dw_1, 0, 0, 100, 100))

4 Add the tab page user object to a Tab control. If there are no embedded tab pages

If a Tab control contains only tab page user objects based on u_tabpg (but not embedded tab pages), you need not enable the resize service for the Tab control.

5 If the Tab control is a user object, add it to a window.

6 Enable the resize service for the window and register affected controls (this example is from the Constructor event):

this.of_SetResize(TRUE) this.inv_resize.of_Register & (tab_1, 0, 0, 100, 100) this.inv_resize.of_Register & (cb_cancel, & this.inv_resize.FIXEDTOBOTTOM) this.inv_resize.of_Register & (cb_ok, & this.inv_resize.FIXEDTOBOTTOM) this.inv_resize.of_SetMinSize & (this.width - 100, this.height - 100)

v To use the resize service with tab page user objects that have the Create on Demand property:

1 In the User Object painter, display the Position tab of the object’s property sheet to determine what the size will be at creation time.

2 Specify the original size by calling the of_SetOrigSize function (this example is from the tab page’s Constructor event):

3 Register tab page controls:

this.inv_resize.of_Register & (this.dw_1, 0, 0, 100, 100))

4 Trigger the Resize event on the UserObject (this example is from the Tab control’s Constructor event):

// The Resize event moves registered // objects, as appropriate.

this.tabpage_1.TriggerEvent(Resize!)

In document pfcug (Page 175-179)