[vwnc] Font changing - programmatically

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Font changing - programmatically

david.long
Hi everyone,

I am working on changing the font for all the widgets in my application. I tried setting the default font in TextAttributes but it is only effecting a few things.

How do you change the font for a SubCanvas and all the components it contains? Is there an relatively easy way to do this?

thanks,

David
-- 

CEO
SageTea Group
613 722 2091 x 5
http://sageteagroup.com

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

[vwnc] Auto indent in code browser available?

Paul-404
Hi everyone,

I'm looking for an auto-indent functionality in the code browser of VW7, is it possible?
Thanks,

Paul Weustink

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Auto indent in code browser available?

thomas.hawker

Paul,

 

There used to be an auto-indent package, but assuming one isn’t there, this gets kind of tricky.  The TextEditorController is the class you must extend or subclass, and you want to be careful because this is also the superclass of all the input widgets, which you don’t want to change.

 

Basically, if you can’t find a suitable capability, I would do this as follows (the easy case):

 

  1. Create a package.
  2. Create a subclass of TextEditorController in the package called IndentingTextEditorController.
    1. Give the new class a shared variable to control auto-indent behavior.
    2. Provide shared variable accessors in class side of IndentingTextEditorController.
    3. Make sure the accessor lazy-initializes the shared variable (never returns nil).
  3. Add a setting control for the default state (the shared variable’s value) – essential for debugging.
  4. Implement the displayCRKey: method, as follows:
    1. If the shared variable is false, invoke super.
    2. Otherwise, from the current selection, find the end of the previous line.
    3. Copy all white space at the beginning of the line, append a CR, and insert that at the selection.  (See the #displayCRKey: method in ParagraphEditor.)
    4. You can try to be smart and eliminate white space on empty lines, but that might do strange things to the undo capability [such as it is].
  5. Add an override of TextEditorView>>defaultControllerClass to use IndentingTextEditorController.

 

To debug your changes:

 

  1. Open the settings dialog.
  2. Turn on indenting and apply.
  3. Open a new browser to see whether you’ve broken anything.
  4. If you have:
    1. Try to close the broken browser.
    2. Turn off indenting in the settings dialog and apply.
    3. Make any fixes you find are needed.
  5. Repeat as necessary.

 

You can implement an indentation instance variable if you want to permit control per code pane.  [Lazy] initialize the instance variable to false.  Add a menu item to the appropriate tool to permit changing the indentation setting.  Add a #postOpenWith: method to set the indentation state to that of the shared variable.  Last, change the displayCRKey: method to look at the instance variable (through its accessor) rather than the shared variable (through its accessor).

                                               

Cheers!

 

Tom Hawker

Senior Framework Developer

Home

+1 (408) 274-4128

The Environment:

We take it personally

Office

+1 (408) 576-6591

Mobile

+1 (408) 835-3643

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Paul
Sent: Tuesday, June 30, 2009 7:22 AM
To: VWNC List
Subject: [vwnc] Auto indent in code browser available?

 

Hi everyone,

I'm looking for an auto-indent functionality in the code browser of VW7, is it possible?
Thanks,

Paul Weustink

IMPORTANT NOTICE
Email from OOCL is confidential and may be legally privileged.  If it is not
intended for you, please delete it immediately unread.  The internet
cannot guarantee that this communication is free of viruses, interception
or interference and anyone who communicates with us by email is taken
to accept the risks in doing so.  Without limitation, OOCL and its affiliates
accept no liability whatsoever and howsoever arising in connection with
the use of this email.  Under no circumstances shall this email constitute
a binding agreement to carry or for provision of carriage services by OOCL,
which is subject to the availability of carrier's equipment and vessels and
the terms and conditions of OOCL's standard bill of lading which is also
available at http://www.oocl.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Font changing - programmatically

Steven Kelly
In reply to this post by david.long

Fonts are defined in both TextAttributes and the current LookPolicy (e.g. WinXPLookPolicy>>defaultSystemFontDescription). If you want your app to look like a native app, you’re best to make sure all widgets use the #system pseudofont rather than the #default. Some widgets are like that anyway by default, but at least lists used to use the #default font from TextAttributes, which is a rather larger font than #system and looks out of place in a Windows app.

 

You’ll also find that its somewhat hard to get font changes to show up everywhere, even everywhere that font is used. That’s because there’s quite a lot of caching going on. Reinitializing the appropriate parts of the LookPolicy and TextAttributes classes and sending “TextAttributes resetViews” will help for part of this, but I seem to recall another incantation or two is needed. Remember to make similar changes in VariableSizeTextAttributes too.

 

Platform, screen resolution and locale all also have an effect on fonts. It’s thus wise to think first about how you want your app to look (and to change its look like a chameleon) in all these various situations, before changing “the font for all the widgets”.

 

Hope this helps,

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Long
Sent: 30 June 2009 14:09
To: 'VWNC'
Subject: [vwnc] Font changing - programmatically

 

Hi everyone,

I am working on changing the font for all the widgets in my application. I tried setting the default font in TextAttributes but it is only effecting a few things.

How do you change the font for a SubCanvas and all the components it contains? Is there an relatively easy way to do this?

thanks,

David

 
-- 
 
CEO
SageTea Group
613 722 2091 x 5
http://sageteagroup.com

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Font changing - programmatically

Stew MacLean
In reply to this post by david.long

Hi David,

 

Having “been there, done that” (with help from Steve, et al) hopefully the code below will save you A LOT of time. This area is complex!

 

Hopefully you can sift through and adapt to your own requirements.

 

Cheers,

 

Stewart

 

This code is for VW7.6.

 

First some documentation…

 

_lookDocumentation

           

            "From UILookPolicy class:

 

            systemAttributes                                   <TextAttributes | nil>      the system text style.  If nil use TextAttributes default.

            systemMenuAttributes   <TextAttributes | nil>      the system menu label text style.  If nil use systemAttributes instead.

            systemWidgetAttributes <TextAttributes | nil>

                        the text style used in SimpleDialogs and on widgets if useSystemFontOnWidgets is true.

                        nil means use systemAttributes instead.

            useSystemFontOnWidgets         <Boolean>        whether system font should be used on widgets.

 

            The actual concrete font used is found by sending currentFont to the TextAttributes.

            This matches the preferred FontDescription to the available fonts via

            FontPolicy>>findFont: aFontDescription

            which measures the fit via

            FontPolicy>>measureDistancesFrom: requestedFont to: concreteFont stopAt: limit.

 

            updatedQueryFor: takes the defaultQuery and adjusts the default values depending on a

            number of factors. See the internals of updateQueryFor:

 

This method installs a new LookPolicy and calls the methods below.

 

installLookPolicyClass: aClass

 

            "Note: MSWindowsFont>>defaultFontDescriptionIn: fontPolicy has been overriden to change the

            fonts that get used."

 

            aClass

                        ifNil: [^self]

                        ifNotNil: [self lookPolicyClass: aClass].

 

            self

                        logLookSeparatorLine;

                        log: 'Installing look policy <1p>...' with: self lookPolicyClass;

                        logLook: ''.

 

            UIBuilder defaultPolicyClass == aClass   "Don't reinstall, if already installed."

                        ifFalse:

                                    [UIBuilder defaultPolicyClass: aClass.

                                    "Through the change/update mechanisim the following gets executed...

                                    ...         aClass installLookPreferences.

                                                GraphicsDevice allOpenDevices do: [:each | each updateWidgetPolicy].

                                                Screen default updateWidgetPolicy"].

 

            UIBuilder defaultPolicyClass initialize.      "Clears class variables..."

            "Needs to be true, so that systemWidgetAttributes gets used, rather than systemAttributes"

            UIBuilder defaultPolicyClass useSystemFontsOnWidgets: true.

            SymbolicPaint reinitializeAllSymbolicInformation.  "Initialises WidgetPolicy defaultWigetColors class variable (need for new Vista look)."

           

            "Install any non default styles (if any)."

            ((self installTextStyle: self textStyle)

            | (self installWidgetStyle: self widgetStyle)

            | (self installMenuStyle: self widgetStyle deepCopy))  "self menuStyle - uses same font as widgets for menus"

                        ifTrue: [TextAttributes resetViews].

 

            "Restore the ui, as it intermittently collapses when changing looks."

            self ui ifNotNil: [: value | value restore]

 

 

 

installTextStyle: aTextAttributes

 

            "Install aTextAttributes as:

           

            a) the value for #default, #systemDefault, and #'crunch style' within Graphics.TextAttributes.TextStyles

            b) the font that is used by VisualWorks to display textual information.

            This is stored in Graphics.TextConstants.DefaultTextStyle and set by sending

            TextAttributes setDefaultTo: aStyleName (which must have been previously defined within TextStyles),

            and is obtained via TextAttributes class>>default.

            c) the value of the systemAttributes class variable within the current UILookPolicy class

            See _lookDocumentation in this class."

                       

            | styleName |

 

            aTextAttributes

                        ifNil: [^false]

                        ifNotNil: [self textStyle: aTextAttributes].

 

            self

                        logLookSeparatorLine;

                        logLook: 'Installing text style...'.

 

            TextAttributes

                        styleNamed: (styleName := ('<1s> style' with: self baseName) asSymbol) put: aTextAttributes;

                        setDefaultTo: styleName;

                        styleNamed: #systemDefault put: aTextAttributes;

                        styleNamed: #default put: aTextAttributes.

 

            "flushFonts, set FontPolicy?"

            aTextAttributes characterAttributes

                        invalidateQueryCache;

                        updatedQueryFor: Screen default defaultFontPolicy.

            "Causes flushGridding, to be invoked."

            Locale changed: #localeFonts with: true.

            InputManager setDefault.

           

            self logLook: 'Text style installed...'.

 

            ^true

installWidgetStyle: aTextAttributes

 

                                                  "Note: the initial widget font is set within the deployed system during packaging via configureData.

                                                  Currently this is for XP and Vista only. The others are the system defaults."

 

                                                  aTextAttributes

                                                            ifNil: [^false]

                                                            ifNotNil: [self widgetStyle: aTextAttributes].

 

                                                  self

                                                            logLookSeparatorLine;

                                                            logLook: 'Installing widget style...'.

 

                                                  "Tried this when having problem as a result of subtle scaling bug... leave incase need.

                                                  aTextAttributes scalingFactor: 1.

                                                  aTextAttributes characterAttributes enableScaling. noScaling; scalingFactor: 1."

                                                  LookPreferences widgetPolicy lookPolicyClass

                                                            systemWidgetTextStyle: aTextAttributes.

 

                                                  aTextAttributes characterAttributes

                                                            invalidateQueryCache;

                                                            updatedQueryFor: Screen default defaultFontPolicy.

                                                  "Causes flushGridding, to be invoked."

                                                  Locale changed: #localeFonts with: true.

                                                  InputManager setDefault.

 

                                                  self logLook: 'Widget style installed...'.

 

                                                  ^true

installMenuStyle: aTextAttributes

 

                                                  "Note: the initial widget font is set during packaging via CrunchConfiguration>>configureData.

                                                  Works when just changing the widget style. Changing the look seems to behave differently.

                                                  See below for previous version previously embedded within installTextStyle:

                                                  Investigation notes:

                                                  Screen default defaultFontPolicy. FontPolicy

                                                  textStyle:

                                                  PlatformCharacterAttributes"

 

                                                  aTextAttributes

                                                            ifNil: [^false]

                                                            ifNotNil: [self menuStyle: aTextAttributes].

 

                                                  self

                                                            logLookSeparatorLine;

                                                            logLook: 'Installing menu style...'.

 

                                                  "Tried this when having problem as a result of subtle scaling bug... leave incase need.

                                                  aTextAttributes scalingFactor: 1.

                                                  aTextAttributes characterAttributes enableScaling. noScaling; scalingFactor: 1."

                                                  LookPreferences widgetPolicy lookPolicyClass

                                                            systemMenuAttributes: aTextAttributes.

 

                                                  aTextAttributes characterAttributes

                                                            invalidateQueryCache;

                                                            updatedQueryFor: Screen default defaultFontPolicy.

                                                  "Causes flushGridding, to be invoked."

                                                  Locale changed: #localeFonts with: true.

                                                  InputManager setDefault.

                                                 

                                                  self logLook: 'Widget style installed...'.

 

                                                  "Previous version embedded within installTextStyle:...

                                                  Keep the System Menu Text style in synch."

                                                  "LookPreferences widgetPolicy lookPolicyClass

                                                            systemMenuAttributes: nil;         ""Need to set this to nil for menu fonts to change, FKW?""

                                                            setSystemTextStyle: TextAttributes default."

 

                                                  ^true

 

Good luck!

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of David Long
Sent: 30 June 2009 11:09 p.m.
To: 'VWNC'
Subject: [vwnc] Font changing - programmatically

 

Hi everyone,

I am working on changing the font for all the widgets in my application. I tried setting the default font in TextAttributes but it is only effecting a few things.

How do you change the font for a SubCanvas and all the components it contains? Is there an relatively easy way to do this?

thanks,

David

 
-- 
 
CEO
SageTea Group
613 722 2091 x 5
http://sageteagroup.com

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Font changing - programmatically

david.long
right on dudes...I will give this code a shot...after July 1 - Canada
Day festivities...will let u know how it goes..

regards,

David

On Wed, 2009-07-01 at 10:54 +1200, Stewart MacLean wrote:

> Hi David,
>
>  
>
> Having “been there, done that” (with help from Steve, et al) hopefully
> the code below will save you A LOT of time. This area is complex!
>
>  
>
> Hopefully you can sift through and adapt to your own requirements.
>
>  
>
> Cheers,
>
>  
>
> Stewart
>
>  
>
>
> This code is for VW7.6.
>
>  
>
> First some documentation…
>
>  
>
> _lookDocumentation
>
>            
>
>             "From UILookPolicy class:
>
>  
>
>             systemAttributes
> <TextAttributes | nil>      the system text style.  If nil use
> TextAttributes default.
>
>             systemMenuAttributes   <TextAttributes | nil>      the
> system menu label text style.  If nil use systemAttributes instead.
>
>             systemWidgetAttributes <TextAttributes | nil>
>
>                         the text style used in SimpleDialogs and on
> widgets if useSystemFontOnWidgets is true.
>
>                         nil means use systemAttributes instead.
>
>             useSystemFontOnWidgets         <Boolean>        whether
> system font should be used on widgets.
>
>  
>
>             The actual concrete font used is found by sending
> currentFont to the TextAttributes.
>
>             This matches the preferred FontDescription to the
> available fonts via
>
>             FontPolicy>>findFont: aFontDescription
>
>             which measures the fit via
>
>             FontPolicy>>measureDistancesFrom: requestedFont to:
> concreteFont stopAt: limit.
>
>  
>
>             updatedQueryFor: takes the defaultQuery and adjusts the
> default values depending on a
>
>             number of factors. See the internals of updateQueryFor:
>
>  
>
>
> This method installs a new LookPolicy and calls the methods below.
>
>  
>
> installLookPolicyClass: aClass
>
>  
>
>             "Note: MSWindowsFont>>defaultFontDescriptionIn: fontPolicy
> has been overriden to change the
>
>             fonts that get used."
>
>  
>
>             aClass
>
>                         ifNil: [^self]
>
>                         ifNotNil: [self lookPolicyClass: aClass].
>
>  
>
>             self
>
>                         logLookSeparatorLine;
>
>                         log: 'Installing look policy <1p>...' with:
> self lookPolicyClass;
>
>                         logLook: ''.
>
>  
>
>             UIBuilder defaultPolicyClass == aClass   "Don't reinstall,
> if already installed."
>
>                         ifFalse:
>
>                                     [UIBuilder defaultPolicyClass:
> aClass.
>
>                                     "Through the change/update
> mechanisim the following gets executed...
>
>                                     ...         aClass
> installLookPreferences.
>
>                                                 GraphicsDevice
> allOpenDevices do: [:each | each updateWidgetPolicy].
>
>                                                 Screen default
> updateWidgetPolicy"].
>
>  
>
>             UIBuilder defaultPolicyClass initialize.      "Clears
> class variables..."
>
>             "Needs to be true, so that systemWidgetAttributes gets
> used, rather than systemAttributes"
>
>             UIBuilder defaultPolicyClass useSystemFontsOnWidgets:
> true.
>
>             SymbolicPaint reinitializeAllSymbolicInformation.
> "Initialises WidgetPolicy defaultWigetColors class variable (need for
> new Vista look)."
>
>            
>
>             "Install any non default styles (if any)."
>
>             ((self installTextStyle: self textStyle)
>
>             | (self installWidgetStyle: self widgetStyle)
>
>             | (self installMenuStyle: self widgetStyle deepCopy))
> "self menuStyle - uses same font as widgets for menus"
>
>                         ifTrue: [TextAttributes resetViews].
>
>  
>
>             "Restore the ui, as it intermittently collapses when
> changing looks."
>
>             self ui ifNotNil: [: value | value restore]
>
>  
>
>  
>
>
>  
>
> installTextStyle: aTextAttributes
>
>  
>
>             "Install aTextAttributes as:
>
>            
>
>             a) the value for #default, #systemDefault, and #'crunch
> style' within Graphics.TextAttributes.TextStyles
>
>             b) the font that is used by VisualWorks to display textual
> information.
>
>             This is stored in Graphics.TextConstants.DefaultTextStyle
> and set by sending
>
>             TextAttributes setDefaultTo: aStyleName (which must have
> been previously defined within TextStyles),
>
>             and is obtained via TextAttributes class>>default.
>
>             c) the value of the systemAttributes class variable within
> the current UILookPolicy class
>
>             See _lookDocumentation in this class."
>
>                        
>
>             | styleName |
>
>  
>
>             aTextAttributes
>
>                         ifNil: [^false]
>
>                         ifNotNil: [self textStyle: aTextAttributes].
>
>  
>
>             self
>
>                         logLookSeparatorLine;
>
>                         logLook: 'Installing text style...'.
>
>  
>
>             TextAttributes
>
>                         styleNamed: (styleName := ('<1s> style' with:
> self baseName) asSymbol) put: aTextAttributes;
>
>                         setDefaultTo: styleName;
>
>                         styleNamed: #systemDefault put:
> aTextAttributes;
>
>                         styleNamed: #default put: aTextAttributes.
>
>  
>
>             "flushFonts, set FontPolicy?"
>
>             aTextAttributes characterAttributes
>
>                         invalidateQueryCache;
>
>                         updatedQueryFor: Screen default
> defaultFontPolicy.
>
>             "Causes flushGridding, to be invoked."
>
>             Locale changed: #localeFonts with: true.
>
>             InputManager setDefault.
>
>            
>
>             self logLook: 'Text style installed...'.
>
>  
>
>             ^true
>
>
> installWidgetStyle: aTextAttributes
>
>  
>
>                                                   "Note: the initial
> widget font is set within the deployed system during packaging via
> configureData.
>
>                                                   Currently this is
> for XP and Vista only. The others are the system defaults."
>
>  
>
>                                                   aTextAttributes
>
>                                                             ifNil:
> [^false]
>
>                                                             ifNotNil:
> [self widgetStyle: aTextAttributes].
>
>  
>
>                                                   self
>
>
> logLookSeparatorLine;
>
>                                                             logLook:
> 'Installing widget style...'.
>
>  
>
>                                                   "Tried this when
> having problem as a result of subtle scaling bug... leave incase need.
>
>                                                   aTextAttributes
> scalingFactor: 1.
>
>                                                   aTextAttributes
> characterAttributes enableScaling. noScaling; scalingFactor: 1."
>
>                                                   LookPreferences
> widgetPolicy lookPolicyClass
>
>
> systemWidgetTextStyle: aTextAttributes.
>
>  
>
>                                                   aTextAttributes
> characterAttributes
>
>
> invalidateQueryCache;
>
>
> updatedQueryFor: Screen default defaultFontPolicy.
>
>                                                   "Causes
> flushGridding, to be invoked."
>
>                                                   Locale changed:
> #localeFonts with: true.
>
>                                                   InputManager
> setDefault.
>
>  
>
>                                                   self logLook:
> 'Widget style installed...'.
>
>  
>
>                                                   ^true
>
>
> installMenuStyle: aTextAttributes
>
>  
>
>                                                   "Note: the initial
> widget font is set during packaging via
> CrunchConfiguration>>configureData.
>
>                                                   Works when just
> changing the widget style. Changing the look seems to behave
> differently.
>
>                                                   See below for
> previous version previously embedded within installTextStyle:
>
>                                                   Investigation notes:
>
>                                                   Screen default
> defaultFontPolicy. FontPolicy
>
>                                                   textStyle:
>
>
> PlatformCharacterAttributes"
>
>  
>
>                                                   aTextAttributes
>
>                                                             ifNil:
> [^false]
>
>                                                             ifNotNil:
> [self menuStyle: aTextAttributes].
>
>  
>
>                                                   self
>
>
> logLookSeparatorLine;
>
>                                                             logLook:
> 'Installing menu style...'.
>
>  
>
>                                                   "Tried this when
> having problem as a result of subtle scaling bug... leave incase need.
>
>                                                   aTextAttributes
> scalingFactor: 1.
>
>                                                   aTextAttributes
> characterAttributes enableScaling. noScaling; scalingFactor: 1."
>
>                                                   LookPreferences
> widgetPolicy lookPolicyClass
>
>
> systemMenuAttributes: aTextAttributes.
>
>  
>
>                                                   aTextAttributes
> characterAttributes
>
>
> invalidateQueryCache;
>
>
> updatedQueryFor: Screen default defaultFontPolicy.
>
>                                                   "Causes
> flushGridding, to be invoked."
>
>                                                   Locale changed:
> #localeFonts with: true.
>
>                                                   InputManager
> setDefault.
>
>                                                  
>
>                                                   self logLook:
> 'Widget style installed...'.
>
>  
>
>                                                   "Previous version
> embedded within installTextStyle:...
>
>                                                   Keep the System Menu
> Text style in synch."
>
>                                                   "LookPreferences
> widgetPolicy lookPolicyClass
>
>
> systemMenuAttributes: nil;         ""Need to set this to nil for menu
> fonts to change, FKW?""
>
>
> setSystemTextStyle: TextAttributes default."
>
>  
>
>                                                   ^true
>
>
>  
>
> Good luck!
>
>  
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of David Long
> Sent: 30 June 2009 11:09 p.m.
> To: 'VWNC'
> Subject: [vwnc] Font changing - programmatically
>
>  
>
> Hi everyone,
>
> I am working on changing the font for all the widgets in my
> application. I tried setting the default font in TextAttributes but it
> is only effecting a few things.
>
> How do you change the font for a SubCanvas and all the components it
> contains? Is there an relatively easy way to do this?
>
> thanks,
>
> David
>
>  
> --
>  
> CEO
> SageTea Group
> 613 722 2091 x 5
> http://sageteagroup.com
>
>  
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc