How Do I Define Reusable Interface Objects? (Magic xpa 4.x)
One of the challenges of today’s programming is maintaining a consistent look and feel across hundreds of open windows, browsers, and reports. Gone are the days of simple text green screens; today you have a choice of hundreds of fonts, sizes, and colors. Setting these choices for each object is horribly time-consuming, and keeping them consistent or making changes is next to impossible, if they are set on an object-by-object basis.
Fortunately, Magic xpa makes this sort of thing incredibly easy. Magic xpa contains a robust system of models, which can be used to define the look and feel of every interface object, including text fields, radio buttons, tables, table columns, print formats, Web browser screens, and Windows windows.
When these are set up as models, using them is easy: you just choose the model you want while designing your form. Changing them is even easier: you change the model, and all items that use that model change automatically.
Here we will give an example of setting up a simple model for a field prompt.
-
Go to the Model repository (Shift+F1), and move to the desired location.
-
Press F4 (Edit->Create Line).
-
Type in the name of the model (here it is “Required Field Prompt”).
-
Select the class you need, such as:
-
GUI Display: for any online screen control, which is what we are using in our example.
-
GUI Output: for most formatted reports
-
Text-based: for text-only output going to another product or older printer.
-
Browser: for Browser controls.
-
Select the attribute. The list of attributes changes, depending on the class of the model. Here, you can see the standard list of GUI display (online screen) items. For our example, we select Static, because we are dealing with static text.
Finally, you need to change the properties. The list of properties will change, depending on the class and attribute.
-
In this case, we are creating a prompt that will be bolder than other field prompts, so we use a different font. Also we want the style to be 2-D, not the default 3-D.
After you are done creating the model, you can use it when creating controls to automatically format them or attach your model to a data type to automatically format it wherever it is used (How Do I Unify and Standardize the Project’s Data Fields and Visual Controls?).