GDI对象的初始化
GDI對象的初始化
一、GR_GraphicsFactory對象的初始化
在XAP_App對象的構造函數中創建GR_GraphicsFactory對象。在XAP_Win32App構造函數中,調用GR_GraphicsFactory對象的
registerClass函數初始化m_vAllocators、m_vDescriptors、m_vClassIds集合成員變量,前兩個分別是GR_Allocator、GR_Descriptor
函數指針。
二、GR_Graphics對象的初始化
在XAP_Win32FrameImpl::_createDocumentWindow函數中,根據各個窗口句柄創建GR_Graphics對象實例。
/* Create Graphics */
GR_Win32AllocInfo ai(GetDC(m_hwndContainer), m_hwndContainer);
GR_Win32Graphics * pG = (GR_Win32Graphics *)XAP_App::getApp()->newGraphics(ai);
函數內部調用GR_GraphicsFactory對象的newGraphics函數
主要有:m_hwndContainer、m_hwndTopRuler、m_hwndLeftRuler、m_hwndDocument、m_hwndTopRuler、m_hwndLeftRuler
根據窗口句柄創建六個GR_Graphics對象。
三、GR_Font對象的初始化
1、FL_DocLayout對象在初始化時需要PD_Document和GR_Graphics對象的實例。GR_Graphics實例是用m_hwndDocument句柄
創建的對象。
2、創建字體對象實例
FL_DocLayout::findFont中調用GR_Graphics對象的findFont函數查找字體。首先,根據
pszFontFamily, pszFontStyle, pszFontVariant, pszFontWeight, pszFontStretch, pszFontSize屬性組成的鍵,查找
m_hashFontCache集合中是否存在該字體,如果找到返回該字體,否則,創建新的字體。
3、查找字體屬性
fp_Run::lookupProperties函數中
const PP_AttrProp * pSpanAP = NULL;
const PP_AttrProp * pBlockAP = NULL;
const PP_AttrProp * pSectionAP = NULL;?
初始化這三個變量。然后調用虛函數_lookupProperties,這個函數中會調用FL_DocLayout的findFont函數查找或創建字體
四、輸入字符
1、創建fp_TextRun對象
首先在fl_BlockLayout::_doInsertTextSpan函數中初始化GR_Itemization對象,在fl_BlockLayout::itemizeSpan函數中根據各個元素的字體屬性信息查找字體,設置GR_Itemization的語言、字體等,最后調用GR_Win32USPGraphics::itemize函數,初始化GR_Win32USPItem對象。
其次,根據GR_Itemization對象創建fp_TextRun對象,調用fp_TextRun::setItem函數,設置GR_Item對象
2、計算字符的寬度,初始化m_pRenderInfo對象
首先,創建GR_ShapingInfo對象,調用GR_Win32USPGraphics::shape函數,創建GR_Win32USPRenderInfo對象實例
并且初始化
其次,在fp_TextRun::measureCharWidths函數中調用GR_Win32USPGraphics::measureRenderedCharWidths函數,計算字符的寬度。
3、輸出字符
在fp_TextRun::_draw函數中畫字符。
轉載于:https://www.cnblogs.com/songtzu/p/3539768.html
總結
- 上一篇: webform数据导出
- 下一篇: Redis 官方文档译注