This Question is Answered

1 "correct" answer available (8 pts) 15 "helpful" answers available (5 pts)
9 Replies Last post: Nov 14, 2008 12:00 AM by ABC XYZ  
ABC XYZ BlackBelt 285 posts since
Mar 6, 2008
Currently Being Moderated

Nov 7, 2008 1:43 AM

Global Font-Color Options

Hi

 

I have set my document style to "Plain Document" and setting the document properties with "set-document-properties" proc in the start file after "applet" herlad like below ...


{document-style PlainDocument}
{set-document-properties
    border-width=1pt,
    border-color="gray",
    font-family = "Arial",
    font-size = 10pt,
    font-style = "normal",
    font-weight = "normal",
    vstretch? = true,
    hstretch? = true
}

But this font styles are NOT applying to my application globally.

 

I want a single place where I can change my application's font styles which will be applied to the whole application and its controls.

 

How to do that ?

 

Thank you

fukuta BlackBelt 146 posts since
Oct 17, 2007
Currently Being Moderated
1. Nov 7, 2008 2:35 AM in response to: ABC XYZ
Re: Global Font-Color Options

Maybe you don't consider the effect of control-appearance-changeable? option. Controls will look for their option values from look-and-feel rather than their option parent when the control-appearance-changeable? is false, the default value of it.

Duke BlackBelt 297 posts since
Oct 17, 2007
Currently Being Moderated
3. Nov 10, 2008 12:40 AM in response to: ABC XYZ
Re: Global Font-Color Options

What are some of the kinds of controls that are still not being affected by your font change?

fukuta BlackBelt 146 posts since
Oct 17, 2007
Currently Being Moderated
5. Nov 10, 2008 1:31 AM in response to: ABC XYZ
Re: Global Font-Color Options

Dialogs (and some other containers) are affected another property named use-look-and-feel?. By default, use-look-and-feel?=true, dialogs also get their nonlocal option values from look-and-feel. Please set it to false and see the result.

fukuta BlackBelt 146 posts since
Oct 17, 2007
Currently Being Moderated
7. Nov 13, 2008 8:04 AM in response to: ABC XYZ
Re: Global Font-Color Options

I can't imagine your situation. I hope someone else solves your problem...

Mike BlackBelt 70 posts since
Oct 17, 2007
Currently Being Moderated
8. Nov 13, 2008 2:54 PM in response to: ABC XYZ
Re: Global Font-Color Options

Curl is a system designed for building both documents and applications, and the requirements sometimes conflict. In particular, most windowing systems use one set of fonts for dialogs and a different set of fonts for the application. The application font is often user settable (so is the system font, but a change at that level affects all applications on the system). In Curl, controls have to live in both worlds. Sometimes they appear in the flow of a document, and sometimes they appear on a dialog, menu, or toolbar. This sounds like the problem you're running into.

 

Graphical objects in Curl usually inherit many properties, including the font attributes. Because they can be inherited, these properties are called "nonlocal options". Each object has an "option parent" from which it can inherit such options. In the case of a Control, the option parent is the "LookAndFeel" object. For other visual objects, the option parent is the graphical container of the object.

 

When you call set-document-properties, you are setting option values almost at the very top of the hierarchy (user preferences are the very top). So you haven't done anything about the controls.  Three solutions come to mind.

 

As someone else suggested, you can set control-appearance-changeable?=true on each control, which tells the control to inherit from the container directly, ignoring the look and feel. You also have to set use-look-and-feel?=false on every Dialog, HttpForm, MenuBar, and MenuPane to tell these objects not to inherit from the look and feel.

 

A nicer solution that works in both 6.0 and 7.0 is the following procedure, which you can call in place of set-document-properties. It calls set-document-properties and then it iterates over the arguments to set the same options on the look and feel, which will insure that the same options are used on controls, dialogs, and so on.

 

The third solution is to use a style sheet, but that's another story.

 

{curl 6.0, 7.0 applet}
{define-proc public {set-properties-everywhere ...}:void
    {set-document-properties {splice ...}}

    {for (arg, keyword) in ... do
        {if keyword != null then
            {the-default-look-and-feel.set-option-by-name 
                {non-null keyword}, arg
            }
         else
            {error Unrecognized argument:  & arg}
        }
    }
}

{Dialog
    margin = 9pt,
    {VBox
        spacing = 9pt,
        {CommandButton},
        {CommandButton control-appearance-changeable?=true},
        {CheckButton},
        {TextField}
    }
}


{CommandButton
    label = Change All,
    {on Action do
        {set-properties-everywhere
            border-width=1pt,
            border-color=gray,
            font-family = Times New Roman,
            font-size = 10pt,
            font-style = normal,
            font-weight = normal
        }
    }
}

 

Note that this sets the border-width on every control, which is probably not what you really want (though it is what you were passing to set-document-properties). If so, you might want to call set-properties-everywhere for most of the options (because you really do want them everywhere), and set-document-properties for the few that you really only want to apply to the document.

More Like This

  • Retrieving data ...