金山衛士UI原理解析 2 CBkWindow

2021-09-07 23:31:11 字數 4218 閱讀 1820

一.cbkwindow

cbkwindow相當於傳統win32的窗體類,但並非每個窗體有一句柄,而是把把乙個hwnd當作乙個容器

同時其還包含乙個bkwnds,bkwnds是乙個單例類,其包含多個cbkwindow

cbkwindow繼承自cbkobject

1.共有屬性

bkwin_declare_attributes_begin()

bkwin_style_attribute("class", m_style, true)

bkwin_int_attribute("id", m_ucmdid, false)//, 0)

bkwin_color_attribute("crbg", m_style.m_crbg, false)

bkwin_color_attribute("crtext", m_style.m_crtext, false)

bkwin_font_attribute("font", m_style.m_fttext, false)

bkwin_tstring_attribute("href", m_strlinkurl, false)

bkwin_tstring_attribute("tip", m_strtooltiptext, false)

bkwin_enum_attribute("valign", uint, true)

bkwin_enum_value("top", valign_top)

bkwin_enum_value("middle", valign_middle)

bkwin_enum_value("bottom", valign_bottom)

bkwin_enum_end(m_uvalign)

bkwin_enum_attribute("align", uint, true)

bkwin_enum_value("left", align_left)

bkwin_enum_value("center", align_center)

bkwin_enum_value("right", align_right)

bkwin_enum_end(m_uhalign)

bkwin_custom_attribute("pos", onattributeposchange)

bkwin_int_attribute("transparent", m_btransparent, false)//, 0)

bkwin_declare_attributes_end()

2.必要的訊息

為重繪和控制項定位等做準備

bkwin_begin_msg_map()

msg_wm_create(oncreate)

msg_wm_paint(onpaint)

msg_wm_destroy(ondestroy)

msg_wm_windowposchanged(onwindowposchanged)

msg_wm_nccalcsize(onnccalcsize)

msg_wm_showwindow(onshowwindow)

bkwin_end_msg_map_base()

3.load方法

其會解析每個xml的節點,並初始化cbkwindow的資料

4.onpaint

beforepaint用於獲取style的樣式

afterpaint用於恢復原先樣式資訊.

bkstyle類定義了樣式資訊

void 

beforepaint(cdchandle &dc, bkdcpaint &bkdc)

if (clr_invalid != m_style.m_crbg)

if (m_style.m_fttext)

hftdraw = m_style.m_fttext;

if (m_style.m_crtext != clr_invalid)

crdraw = m_style.m_crtext;

if (isdisabled(true)/*bkwndstate_disable == (getstate() & bkwndstate_disable)*/)

else if (bkwndstate_hover == (getstate() & bkwndstate_hover))

if (hftdraw)

if (crdraw != clr_invalid)

}void

afterpaint(cdchandle &dc, bkdcpaint &bkdc)

// draw inner text default

void

onpaint(cdchandle dc)

二.bkstyle

同skin一樣,也是從xml載入資源

<

style

>

<

class

name

=mainhead skin

=mainbghead font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=mainbody skin

=mainbgbody font

=0000 crtext

=ffffff crbg

=fbfcfd x-margin=7

/>

<

class

name

=mainfoot skin

=mainbgfoot font

=0000 crtext

=000000 crbg

=fbfcfd x-margin

=10 y-margin=1

/>

<

class

name

=msgboxhead skin

=msgboxhead font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=msgboxbody skin

=msgboxbody font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=msgboxfoot skin

=msgboxfoot font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=dlgbody skin

=dlgbody font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=dlgfoot skin

=dlgfoot font

=0000 crtext

=000000 crbg

=fbfcfd

/>

<

class

name

=linktext font

=0002 hoverfont

=0002 crtext

=3064a5 crhover

=ff0000 cursor

=hand

/>

<

class

name

=linktext2 crtext

=3064a5 crhover

=ff0000 cursor

=hand

/>

<

class

name

=linktext3 font

=0002 hoverfont

=0002 crtext

=0051e5 crhover

=ff0000 cursor

=hand

/>

…style

>

金山衛士介面原始碼解讀及介面庫分離 2

前面已經發布了分離後的kui 我們繼續,下面來解釋該 庫的使用.首先要說下kui框架的一些基礎概念 一 金山介面庫不使用windows的視窗布局,只是使用windows的視窗作為乙個載體,整個視窗都只是作為乙個繪製面,而kui對視窗實行重新布局,取消了原視窗非客戶區和客戶區的概念.而自己對視窗劃分為...

LCD原理解析

硬體體系 3個部分 lcd液晶 屏 lcd驅動晶元 lcd控制器 整合在arm晶元內部 控制器 通過驅動晶元 控制液晶屏 液晶屏種類 stn gf tft tft 在嵌入式中較為常用 lcd控制器結構與模組 由17個可程式設計的暫存器組和一塊 256 16的調色盤內 存組成,通過這些暫存器,可以配置...

session原理解析

首先session跟cookies都是會會話進行跟蹤,session通過在伺服器端記錄資訊來記錄,cookies通過在客戶端記錄資訊來記錄。在此只對session進行分析 session是記錄在伺服器記憶體中的,每當乙個使用者通過瀏覽器第一次進行訪問時進行建立 需要注意只有訪問jsp,servlet...