Skip to content

DS Archive Support Website

Sections
Personal tools

Text Styles

Text styles allow the text and background color and font settings used to display data to be controlled.

Overview

The text in DataSplice grids can now be customized using the Text Style (DS_TEXT_STYLE) attribute, which allows the text and background color to be specified, along with several text attributes such as italics, bold, etc.

The default settings should look pretty much the same as DataSplice 3.0, but the settings can be changed at a system/view/field level for various purposes. This will support both changing the default colors to accomodate a special need (i.e. color blindness) or using colors to convey additional information (i.e. show errors in red, warnings in yellow, etc).

Syntax

The basic syntax is somewhat reminiscent of CSS, though it is tailored to work for the specific needs of DataSplice. In general, the parser is case-insensitive but most of the examples are shown in all lower case.

Colors

Colors are used to specify both text and background color. Several different types are available:

Named Colors
These include both fixed colors (white, black, gray, red, green, blue, yellow, magenta, and cyan) and windows palette colors (3dface, 3dlight, 3dshadow, activeborder, activecaption, captiontext, desktop, graytext, highlight, highlighttext, inactiveborder, inactivecaption, inactivecaptiontext, menu, menutext, static, statictext, window, windowframe, and windowtext). The palette colors will typically be preferable to fixed colors because they will match well with the rest of the environment. See the documentation for the Windows API function GetSysColor for more information about individual colors.
Web Colors
These specify an RGB color in hexidecimal format (#FF0050). Note that three digit colors (#ABC) are interpreted by doubling the digits (#AABBCC).
Decimal Colors
In addition, RGB colors can be specified with a comma separated list of three decimal intensities from 0 to 1 inclusive (.5,.75,1). The parser is fairly forgiving of whitespace, and should accept any number of decimal places. That this format is easier to use than the web format when building style expressions that are the result of a calculation.

Style Keys

These specify the part of the style that is to be modified by a statement. Some of these keys have a value (text, bg) while other stand on their own (bold, italic). Values are specified with a colon after the key (bg: desktop). Again, the parser is very lenient in consuming whitespace.

  • text - Controls the text color
  • bg - Controls the background color (background can also be used)
  • bold - Specifies whether or not the text is bold
  • italic - Specifies whether or not the text is italic
  • underlined - Specifies whether or not the text is underlined
  • strikeout - Specifies whether or not the text has a strikeout line

Key Modifiers

Each key can have an optional modifier, which controls how it is applied to the style. Modifiers are addied before the style key (-bold, !text: red).

The default (unmodified) is to simply apply the specified setting. For colors, this means to set the color to the specified value and for font style settings this means add the specified style.

  • + (Addition) - Adds the value to the current setting. For colors, this will combine the two colors. For font styles this is the same as the default behavior.
  • - (Subtraction) - Subtracts the value from the current setting. For font styles, this will remove a style.
  • ^ (XOR) - Combines the current and specified colors using an exclusive or operation. This modifier is not valid for font styles.
  • ! (Important) - Specifies that the current setting is important, which prevents it from being overridden by later settings (unless that setting is itself important).

Style Classes

Classes specify different types of text and allow specific settings to be defined for each one. The following classes are defined:

  • normal - Specifies the base text style. This class is always applied.
  • disabled - Defined when a the parent window is disabled.
  • even, odd - Classes defined by the grid in multiple record display mode to support striping.
  • label - Specifies that the cell is a label. Used by the grid in single record mode for the field names.
  • selected - The cell is part of the selected row.
  • active - Specifies that the cell has focus.
  • readonly - Specifies that the current contents cannot be modified.
  • modified - Specifies that the current contents have been locally modified.
  • error - Specifies that the current contents contain an error.
  • deleted - Specifies that the current contents have been marked for deletion.
  • original - Specifies that the value is not modified from the default. This is used by the Administration Client to indicate values that have specific values specified in the configuration.

Text Style Statements

The Text Style attribute should contain a list of statements about the styles to apply for various classes.

Each class statement consists of a space-separated list of one or more class names, followed by a semi-colon separated list of style statements in curly brackets:

<class name> [<class name>] { <style statement>; [<style statement>] }

For instance, a simple statement might look like normal { text: black; bg: white }. This sets the default text and background colors. Another example, error { text: red } error selected { bold }, sets the text color to red and will make the text bold for errors that are in the current record.

Hierarchy

Processing detailed style statements can seem complicated at first, but it follows a straight-forward method to determine the resulting drawing settings.

  • First, a list of the current style classes is generated based on the cell in question. For instance, to paint the focused cell that has been modified by the user, this would contain normal, odd, selected, active, and modified.
  • Next, it walks through the list of style statements defined by the attribute. If each class specified by the statement is in the current list, the style modifiers defined by the statement are applied to the current statement.

Note that this means there is no built-in order to the style classes. Precedence is defined by the order of statements within the entire expression, left-to-right. This means that more general classes (normal) should be on the left, and more specific classes (modified) should be toward the right.

For example, error { text: red } active { text: white } might not be what you want since the active class will overwrite the error settings when a cell has focus. Switching the order of the statements would have the error settings take precedence.

  • Finally, the way text style attributes are merged throughout the hierarchy works a little differently than the normal operation. Text styles can be defined separately for roles, views, and fields, but the default behavior would mean that the entire style setting would need to be reproduced at each level. This would make it difficult to just specify the background color for an individual field.

Instead, the code walks through the list of attribute-containing objects and processes each one that has a Text Style attribute defined. The settings are merged together, with higher-precedence objects being applied later so they overrule earlier settings.

Default Settings

The default text style settings are defined by the TextStyle setting in the application .NET configuration file. This can be changed as part of a distribution, but the same effect can be acheived defining attributes through the Administration Client.

The default style is:

normal { text:windowtext; bg:window }
disabled { text:graytext; bg:windowframe }
readonly { text:#666 }
selected { text:highlighttext; bg: highlight }
odd { ^bg:#111 }
active { text:windowtext; bg:window }
label { text:windowtext; bg:3dface }
label selected { text:captiontext; bg:activecaption; italic }
original { text:#666 }
modified { text:highlight }
selected modified { text:highlighttext }
active modified { text:highlight }
error { text:red; bold }
deleted { strikeout }

A couple of things to note:

  • Most of the settings use system colors so items should match the current color scheme.
  • The odd class uses XOR modifiers to alter the base colors, instead of specifying an explicit color so it works against a broad range of window colors.
 

Last modified 2009-10-13 01:12 PM
 

Powered by Plone

This site conforms to the following standards: