class CGXFont: public CObject
The CGXFont class encapsulates a LOGFONT structure. CGXFont supports serialization and its state can be archived in the registry/profile.
Font objects can be composed. Each attribute of LOGFONT is associated with an include-bit. When an attribute is initialized, it's include-bit is TRUE. If it is FALSE, an attribute is invalid. When drawing the grid, Objective Grid fills up all uninitialized attributes of the cell’s style object with the base style’s attributes. If the GetInclude... methods return FALSE, Objective Grid will try to initialize this attribute with the base style’s setting. If the GetInclude... method return TRUE, the specific setting will be used for drawing.
The following attributes have an include-bit in CGXFont class:
-
Font Weight (Bold, Normal).
-
Italic Style.
-
Underline Style.
-
StrikeOut Style.
-
Font Size.
-
Face Name.
- Orientation
Each attribute is associated with four attribute methods. An example is the font size:
- BOOL GetIncludeSize() const returns the include-bit.
- CGXFont& SetIncludeSize(BOOL bInclude) changes the include-bit.
- LONG GetSize() const returns the font size.
- CGXFont& SetSize(LONG size) changes the font size. This method automatically calls SetIncludeSize(TRUE).
SetIncludeSize and SetSize return the this-pointer, and therefore the programmer can easily initialize several attributes with one statement.
Normally, CGXFont objects are used in styles. The following example illustrates the formatting of some columns.
SetStyleRange(
CGXRange().SetCols(2, 4),
CGXStyle()
.SetFont(
CGXFont()
.SetSize(10)
.SetBold(TRUE) )
);
Support for different character sets
You can assign a specific character set to a cell via SetFaceName().
Example:
SetFaceName("Arial"); - default charset will be used
SetFaceName("Arial (Western)"); - Western charset will be used
SetFaceName("Arial (Cyrillic)"); - Cyrillic charset will be used
You can specify if the character sets should be displayed in the font page of the stylesheet by setting
GXGetAppData()->m_bDisplayFontCharset = TRUE;
The default is FALSE (character sets will not be displayed in the font page).
Note: When you change the font for the standard style in the grid, the row heights and column widths will grow or shrink proportionally with the font size. If you need to know the new row heights and column widths immediately after changing the font size, you should call UpdateFontMetrics.
#include <gxall.h>
See Also
CGXStyle CGXGridCore::UpdateFontMetrics