Screen Panels Intro

Screen Panels Intro

29 September 2003



Starting with version 3.7.4, 4C will allow you to divide a screen program into panels. Both the server and client need to be at or above this release level. There are no known issues of connecting the newer client to an older server, however, even though older clients can connect to newer servers they will crash if they try to run any panel programs. Panels do not affect the logical processing of 4C, although there are some places this could change. (See the Unresolved Issues section.) 4C will still process each display field individually and in the order the fields are defined in sys.dpy_field.

A panel is an area of the screen that can contain other panels (subpanels) or display fields. Panels can have titles and margins. Panels manage the layout of their children, whether they are other panels or display fields. One panel can not contain both subpanels and display fields. Panels work very much like screen layouts and have similar types. If you understand 4C Screen Layouts you will have no trouble understanding 4C Screen Panels. The main difference is that Screen Layouts manage the layout of multiple 4C screen programs, while panels manage the layout of subpanels and of display fields within a single 4C program.

Some advantages of using panels in screen programs are:


Panel Types

The types of panels that 4C allows and how they layout their children follow:


Panel Attributes

There are a lot of different attributes that you can specify along with the panel type. Not all attributes are used by all panel types. Some attributes that you can define are:

Panel sttributes that determine what to do with extra space all work with percentages. They are:

Even though there are reasonable defaults used if none of these values are specified it is a good idea to specify them when you define a panel and to test what happens to your panels when they resize.

Some attributes affect only HRowCol and VRowCol panels. They are:

The attributes that affect only Grid panels are:

There are 2 attributes that allow children to grab more of the extra space available than their siblings. These are used when the parent panel is an HRowCol/HSplitPane or a VRowCol/VSplitPane. Both are percentages of total extra space available. They are:

If you specify a ngative number for either GrabWidth or GrabHeight, then that subpanel will not get any of the extra space even if the other sibling panels grab less than 100 % total.


Defining Panels

There are 2 ways to define panels in 4C. The first method is using 4C bootstrap programs. The other method is to use the windows panel screen painter client program, wpnlsp. Both methods make use of two new bootstrap files. Understanding these files is important in understanding the way panels work. They new files are:

In addition to the 2 new files, there are also 2 new fields in sys.dpy_field that are used by panel programs. The two fields are:

All panels have details. The details can be either other panels or they can be display fields.

One panel cannot have both subpanel and display field details. A panel that has display field details is said to be a leaf panel.

All display fields must be in a panel.

There are several steps involved in making a screen program a screen panel program.

There are currently 2 special panel names, "Root" and "Title". Every panel program must have one Root panel. This panel can be a leaf or a non leaf panel. The Title panel is necessary only if you have display fields that you want in the title bar.

Every display field needs to belong to one and only one panel. As you add display fields to a panel program you need to assign them to a panel. You can do this as you define the display field, or you can do it later using the panel definition screens or with wpnlsp.


Miscellaneous



One additional 4C feature makes using Panels easier. Display fields can have either a top label or a side label associated with them. You can define defaults for these labels in the data dictionary. If defaults are defined, then simply selecting top or side as a label type will set a default label. Scrolldet and lvitem display fields can only have top labels. Using display field labels greatly reduces the clutter in the display field definition screen.

In order to use ListViews, you need to have an lvitem defined in the s_dftype file. Copy from the system directory if necessary.

There are several new font classes that can be added to the 4csfont.def file that affect panels. Look at the entries in the default one in HOME_4C/lib to see what is new.

If you have bootstrap file definitions in your application directory make sure you update them from the system directory.


Examples

Before writing your own panel programs, it may be helpful to see a few in action. There are a bunch of examples currently in the 4cSys application directory. Some of these are just dumb programs that I have been playing with to test different features. Some however are real programs. Some of the more interesting ones are:


Tutorial

The following will guide you through writing your first few panel programs. Before you start, make sure that you have the current file definitions in the application directory you will be using. You can set up a demo application directory suitable for this purpose by:

Follow these steps and you will have your first panel program.
  1. Run the 4cclient and connect to your server and application.
  2. Select Mod Maintenance and add a new mod. Use demo progs as reason.
  3. Select the new mod and then select progs from the context menu.
  4. From the mod prog list select prog specs.
  5. Add a new program with the name demo.panel.1 and category demo. Specify Panel as the program class and Default as the layout.
    Exit this program and you will be back in the mod prog list.
  6. Select AddProg from the mod prog list context menu and enter demo.panel.1 at the Program: prompt.
    After successful add, exit the AddProg dialog.
    You will be back at the mod prog list with demo.panel.1 in the list.
    You can now make modifications to this program.
  7. Goto the PrFiles definition screen for this program and add sys.program.
    Do not enter any driver info.

    Exit PrFiles. You should be back in the main development screen.
  8. Goto the DisplayField definition screen.
    Add two fields, sys.pr_name and sys.pr_catg.
    For both specify inpdata as sdftype and Side as label type.
    Do not add any other info for either field.
    Notice that both fields have labels defaulted from the data dictionary.
  9. Goto the program characteristics screen. From the context menu, select Panels.
  10. Add a new panel, Leave the defaulted values alone for now. We needed to specify 'y' for leaf since this panel is going to contain display fields and not other panels.
  11. Exit Add Mode and enter panel details.
    2 programs should start at the bottom.
  12. Select both available display fields. Then press the AddSelected button. Press ok when prompted. The two fields should show up in the left side program and disappear from the right side program. However, I think there's a bug. If they don't appear on the left, cancel and reenter panel details. They should show up.
  13. Exit back to the main development screen. Compile and run your program.
  14. Play with resizing it. Go back to the panel definitions and see what happens with changing some of the options.
  15. Go back to the display fields program and notice that the panel info shows up there.


Congratulations, you've written a panel program. :)

We will now write a much more complicated program that embeds sub panels and makes use of multiple panel types.

  1. Create a new program named demo.panel.2 and put it on the same mod as demo.panel.1.
  2. Goto PrFiles and add sys.program with no driver options specified.
  3. Goto DpyFields and add the following Fields/SDFType/LabelType
    sys.pr_name,inpdata,Side
    sys.pr_catg,inpdata,Side
    sys.pr_desc,inpdata,Top
    sys.pr_initpcl,inpdata,Side
    sys.pr_flpcl,inpdata,Side
    sys.pr_eflpcl,inpdata,Side
    sys.pr_endpcl,inpdata,Side
    sys.pr_inpflag,chkbox,Side
    sys.pr_drflag,chkbox,Side
    sys.pr_runprog,inpdata,Side
    sys.pr_btstyle,sellist,Side
    
  4. Add the following Literals. Set SDFType to cmdbtn for all 3. Don't specify any LabelType. It will default to None.
    OK
    Apply
    Cancel
    
Now we can define the panels. What we want is a main data entry area on the left and some command buttons on the right. The data entry area will be further divided into some input fields at the top, and a tabfolder at the bottom. The tabfolder wil have two tabs, one that shows the pcl fields and one that shows some program options. Here's how we do it.
  1. Go to the Panel Definition screen. Add the following Panels.
  2. Next add the details for the 4 non leaf panels. Here's how:
  3. Next add the details for the 6 leaf panels. Here's how:
  4. Exit back to the main Prog Development screen.
    Compile and run the program.
    Fix my typos and compile/run again.


Some features of demo.panel.2 worth noting are:

If you can understand the way panels work in this program, then I can consider myself a successful doc writer. Congratulations to both of us. If not, then please call or email and I will do my best to make it clearer.


Panel Type Specifics

Some panel behaviors are related to certain panel types. Some of these are temporary peculiarities that will be fixed in the future. Others are that way because they need to be. Those behaviors are described here.


Unresolved Issues



Back to Top